getOrPut

fun getOrPut(key: K, defaultValue: () -> V): V

Returns the value for key if present, otherwise computes it with defaultValue, stores it, and returns it.

A hit marks the entry most recently used. A miss inserts through put and may evict the least recently used entry.