SafeCache

interface SafeCache<K : Any, V> : HasTraceTags

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.

Types

Link copied to clipboard
object Companion

Functions

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

This is conceptually similar to ConcurrentHashMap.computeIfAbsent.

Properties

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

Inheritors

Link copied to clipboard

Sources

Link copied to clipboard