MemoryCacheManagerBuilder

Builder for a thread safe Cache that internally manages a MemoryCache. The cache will periodically persist its data to a SnapshotPersistentCache and will enforce the given CachePolicy. Once the Cache is no longer in use its coroutineScope should be cancelled.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun build(): Cache<K, V>
Link copied to clipboard
abstract fun cachePolicy(cachePolicy: CachePolicy): MemoryCacheManagerBuilder<K, V>

The CachePolicy to apply to the MemoryCache and its entries.

Link copied to clipboard
abstract fun coroutineScope(coroutineScope: CoroutineScope): MemoryCacheManagerBuilder<K, V>

It is important that the provided coroutineScope live as long as the MemoryCache is in use. Once the coroutineScope is cancelled no further changes to the Cache will be saved to the SnapshotPersistentCache.

Link copied to clipboard
abstract fun dispatcher(dispatcher: CoroutineDispatcher): MemoryCacheManagerBuilder<K, V>

The CoroutineDispatcher to use when reading and writing to the SnapshotPersistentCache. Defaults to Dispatchers.IO.

Link copied to clipboard

Allows the cache to respond to low memory and critical memory notifications according to the callback functions exposed on MemoryLevelNotifier.memoryLevelCallbacks.

Link copied to clipboard
abstract fun saveFrequency(saveFrequency: Duration): MemoryCacheManagerBuilder<K, V>

Controls how soon a snapshot of the MemoryCache is persisted after a change to the Cache. The Duration specified by saveFrequency will elapse between each persisted snapshot. This is in addition to the time it takes to persist the snapshot itself.

Link copied to clipboard
abstract fun telemeter(telemeter: Telemeter): MemoryCacheManagerBuilder<K, V>

The Telemeter to use for logging internal events and errors. Defaults to null (no logging).