getOrSet

open fun getOrSet(key: K, valueGenerator: () -> V): V

Retrieves the cached value corresponding to the provided key, or stores a cache for the key in case it is missing

Return

the value corresponding to key, if any, or the value produced by valueGenerator otherwise

Parameters

key

is the key used for indexing the pair

valueGenerator

is the function aimed at generating the value to be cached