Skip to content

getOrPut

fun <K : Any, V : Any> Cache<K, V>.getOrPut(key: K, compute: (K) -> V): V

Returns the value for the given key if it's contained in the cache, or computes the value with compute outside the cache's computation lock and adds it to the cache.