Cache

interface Cache<K, V>

Interface for cache implementations.

Defines the contract for caching key-value pairs with thread-safe operations.

Inheritors

Functions

Link copied to clipboard
abstract suspend fun clear()

Clear all entries from the cache.

Link copied to clipboard
abstract fun contains(key: K): Boolean

Check if a key exists in the cache.

Link copied to clipboard
abstract fun get(key: K): V?

Get a value from the cache.

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

Get a value or compute and cache it if missing.

Link copied to clipboard
abstract fun isEmpty(): Boolean

Check if cache is empty

Link copied to clipboard
abstract fun keys(): Set<K>

Get all keys in the cache.

Link copied to clipboard
abstract suspend fun put(key: K, value: V)

Store a value in the cache.

Link copied to clipboard
abstract suspend fun remove(key: K): V?

Remove a value from the cache.

Link copied to clipboard
abstract fun size(): Int

Get the number of cached entries.

Link copied to clipboard
abstract fun values(): Collection<V>

Get all values in the cache.