getOrPut

abstract fun getOrPut(key: Key, valueProducer: () -> Value): Value

Return

Value associated with key, obtaining the value from valueProducer if necessary. No observable state associated with this cache is modified until loading completes.

Parameters

valueProducer

Must not return null. It may either return a non-null value or throw an exception.

Throws

ExecutionExeption

If a checked exception was thrown while loading the value.

UncheckedExecutionException

If an unchecked exception was thrown while loading the value.

ExecutionError

If an error was thrown while loading the value.