SafeCache

interface SafeCache<K : Any, V> : HasTraceTags(source)

A thread (and coroutine) -safe cache, with automatic eviction.

When accessing data via getOrPut, the operation inside the lambda is guaranteed to only execute once for each key -- unless the previous data has been evicted from the cache.

Since

0.12.0

Inheritors

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
abstract val tags: Iterable<Any>
Link copied to clipboard
abstract val values: Flow<V>

Functions

Link copied to clipboard
abstract suspend fun getOrPut(key: K, loader: suspend () -> V): V

This is conceptually similar to ConcurrentHashMap.computeIfAbsent.