RepositoryStateFlowCache

open class RepositoryStateFlowCache<K, V, R : MinimalStoreRepository<K, V>>(cacheScope: CoroutineScope, repository: R, rtm: RepositoryTransactionManager, infiniteCache: Boolean = false, cacheDuration: Duration = 1.minutes) : StateFlowCache<K, V>

Constructors

Link copied to clipboard
fun <R : MinimalStoreRepository<K, V>> RepositoryStateFlowCache(cacheScope: CoroutineScope, repository: R, rtm: RepositoryTransactionManager, infiniteCache: Boolean = false, cacheDuration: Duration = 1.minutes)

Functions

Link copied to clipboard
fun get(key: K, withTransaction: Boolean = true, isContainedInCache: suspend (cacheValue: V?) -> Boolean = { it != null }): Flow<V?>
Link copied to clipboard
fun init(initialValues: Map<K, V>)
Link copied to clipboard
fun readWithCache(key: K, isContainedInCache: suspend (cacheValue: V?) -> Boolean, retrieveAndUpdateCache: suspend (cacheValue: V?) -> V?): Flow<V?>
Link copied to clipboard
fun reset()
Link copied to clipboard
suspend fun update(key: K, persistIntoRepository: Boolean = true, withTransaction: Boolean = true, isContainedInCache: suspend (cacheValue: V?) -> Boolean = { it != null }, onPersist: suspend (newValue: V?) -> Unit = {}, updater: suspend (oldValue: V?) -> V?)
Link copied to clipboard
suspend fun writeWithCache(key: K, updater: suspend (oldValue: V?) -> V?, isContainedInCache: suspend (cacheValue: V?) -> Boolean, retrieveAndUpdateCache: suspend (cacheValue: V?) -> V?, persist: suspend (newValue: V?) -> Unit)

Properties

Link copied to clipboard
val cache: SharedFlow<Map<K, StateFlow<V?>>>
Link copied to clipboard
Link copied to clipboard