fun computeIfAbsent(key: K, mappingFunction: Function<in K, out V>): V

Gets the entity in cache under the specified key If no cache entry is found, the mappingFunction is used to create a new entity, which is saved to the cache and returned. Throws an exception if the entity under the provided key is currently computed

Return

the cache entity associated with the provided key

Parameters

key

the key for the cache entity

mappingFunction

used to create the entity if not found in cache

Throws

if the entity under the provided key is currently computed


fun computeIfAbsent(key: K, alternativeIfComputing: V, mappingFunction: Function<in K, out V>): V

Gets the entity in cache under the specified key If no cache entry is found, the mappingFunction is used to create a new entity, which is saved to the cache and returned. If the value is currently computed, returns alternativeIfComputing

Return

the cache entity associated with the provided key

Parameters

key

the key for the cache entity

alternativeIfComputing

alternative return value if value is currently in computation

mappingFunction

used to create the entity if not found in cache

Throws

if the entity under the provided key is currently computed