get

abstract suspend fun get(key: K, valueLookup: suspend (K) -> ExpiringValue<V>): V

Gets the value associated with this key from the cache. If the cache does not contain the given key, implementations are expected to invoke valueLookup, although they may perform other actions such as throw exceptions, fall back to other caches, etc.

Parameters

key

The key for which to look up a value

valueLookup

A possibly-suspending function which returns the read-through value associated with a given key. This function is invoked when the cache does not contain the given key or when the value is expired.