getOrPut

suspend fun getOrPut(key: K, loader: suspend () -> V): V(source)

Gets a cached value or computes and caches it if absent.

Return

the cached or newly computed value

Parameters

key

the cache key

loader

function to compute the value on cache miss