commonMain.contextual.ContextualWrapper.kt Maven / Gradle / Ivy
package opensavvy.cache.contextual
import opensavvy.cache.Cache
import opensavvy.state.coroutines.ProgressiveFlow
/**
* Implementation of [Cache] for a [ContextualCache].
*/
internal class ContextualWrapper(
private val upstream: ContextualCache,
) : Cache, F, V> {
override fun get(id: Pair): ProgressiveFlow {
val (ref, context) = id
return upstream[ref, context]
}
override suspend fun update(values: Collection, V>>) {
upstream.update(values.map {
val (identifier, value) = it
val (id, context) = identifier
Triple(id, context, value)
})
}
override suspend fun expire(ids: Collection>) {
upstream.expireContextual(ids)
}
override suspend fun expireAll() {
upstream.expireAll()
}
}