put

abstract suspend fun put(key: K, creationFunction: suspend (key: K) -> V?): V?

Associates a new value created by creationFunction with the given key.

This function waits for the creation to complete. If the creation fails, the function returns null. Any unhandled exceptions inside the creation block will be thrown. Existing or under-creation values associated with key will be replaced by the new value.

creationFunction should return null only if the creation fails.


abstract suspend fun put(key: K, value: V): V?

Associates the specified value with the specified key in the cache.

Existing or under-creation values associated with key will be replaced by the new value.

Returns: the previous value associated with key, or null if there was no previous value.