Skip to content

NullableConcurrentCache

@JvmInline
value class NullableConcurrentCache<K : Any, V>(val map: ConcurrentMap<K, Any> = ConcurrentHashMap())

A wrapper around a ConcurrentMap which stores null values returned by the computation in the form of explicit objects.

Constructors

NullableConcurrentCache

constructor(map: ConcurrentMap<K, Any> = ConcurrentHashMap())

Properties

map

Functions

getOrPut

inline fun getOrPut(key: K, crossinline 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.