MinimalRepositoryStateFlowCache

open class MinimalRepositoryStateFlowCache<K, V, R : MinimalRepository<K, V>>(cacheScope: CoroutineScope, repository: R, tm: TransactionManager, expireDuration: Duration = 1.minutes) : StateFlowCache<K, V>

Constructors

Link copied to clipboard
constructor(cacheScope: CoroutineScope, repository: R, tm: TransactionManager, expireDuration: Duration = 1.minutes)

Functions

Link copied to clipboard
fun get(key: K, 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 save(key: K, value: V?, isContainedInCache: suspend (cacheValue: V?) -> Boolean = { it != null }, onPersist: suspend (newValue: V?) -> Unit = {})
Link copied to clipboard
suspend fun update(key: K, persistIntoRepository: 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?) -> StateFlow<Boolean>?)

Properties

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