A persistent store to back a cache. This store is considered to be slow by default. Therefore, direct interaction with it to access cached objects should be avoided. The store is useful in certain scenarios.
For example, an in-memory cache can be rehydrated after a cold start of the application by loading from the backing CacheStore.
abstract val blocking: Boolean
Marker whether the store does any blocking I/O. If it is set to true, then it is expected that the calling thread will be blocked. Otherwise, certain method calls on the CacheStore will return immediately and all the operations will be scheduled on a separate worker thread.
abstract val preprocessors: List<CacheStorePreprocessor<Cacheable, Cacheable, Cacheable>>?
Chain of preprocessors to archive and unarchive Cacheable objects. While persisting, the preprocessors are applied to the incoming Cacheable instance and are expected to return an archived Cacheable instance. Before archiving, a CacheStore always adds a special CacheStorePreprocessor at the end of the preprocessors chain which outputs a RawCacheable.
abstract fun fetchAllObjects(): List<Cacheable>
Returns a list containing all the objects persisted in the store. This method is always invoked on the calling thread and is not affected by blocking value.
abstract fun flushAndClose(): <ERROR CLASS><Unit>
Close all the handles to the resources by flushing any scheduled tasks. This method should be used in conjunction when blocking is set to true. The store implementation is expected to guarantee that calling this method will not result in any loss and that all resources will be freed only after the schedules tasks are completed.
abstract fun <T : Cacheable> persistObject(obj: T): Unit
abstract fun unlinkObject(: String): Unit
Deletes an object with the given
abstract fun wipe(): Unit
Calling this method guarantees that all traces of persisted objects are removed from the system. This method is always invoked on the calling thread and is not affected by blocking value.
class DiskStore : CacheStore