RealSafeCache

internal class RealSafeCache<K : Any, V>(val tags: Iterable<Any>, initialValues: List<Pair<K, V>>) : SafeCache<K, V> (source)

Constructors

Link copied to clipboard
constructor(tags: Iterable<Any>, initialValues: List<Pair<K, V>>)

Properties

Link copied to clipboard
private val delegate: Cache<K, LazyDeferred<V>>

Note that the api surface is that of a Cache<K, V>, but this is using a LazyDeferred<V>. This allows all "loader" operations to be light-weight and non-recursive.

Link copied to clipboard
open override val tags: Iterable<Any>
Link copied to clipboard
open override val values: Flow<V>

Functions

Link copied to clipboard
open suspend override fun getOrPut(key: K, loader: suspend () -> V): V

This is conceptually similar to ConcurrentHashMap.computeIfAbsent.