CacheTransaction

interface CacheTransaction<V>

An atomic transaction run on a cache for objects of type V.

Functions

Link copied to clipboard
abstract suspend fun clear()

Clears all cached values.

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

Gets the current cached value for the given key.

Link copied to clipboard
suspend fun <V> CacheTransaction<V>.getOrPut(key: String, defaultValue: suspend () -> V): V

Gets the current cached value for the given key or creates and caches a new one.

Link copied to clipboard
suspend fun <V, F> CacheTransaction<V>.getOrTryPut(key: String, defaultValue: suspend () -> Try<V, F>): Try<V, F>

Gets the current cached value for the given key or creates and caches a new one.

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

Writes the cached value for the given key.

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

Clears the cached value for the given key.