PersistentMap

class PersistentMap<K, V>(options: MapMessageHandlerOptions<K, V>)

A map-like utility that immediately persists all of its contents to disk.

Constructors

Link copied to clipboard
fun <K, V> PersistentMap(options: MapMessageHandlerOptions<K, V>)

Types

Link copied to clipboard
sealed class ProcessResult<V>

Type that signals the result of each item processed in process

Functions

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

Get an value from the map.

Link copied to clipboard
suspend fun process(timeoutMs: Long? = null, block: suspend (Pair<K, V>) -> PersistentMap.ProcessResult<Pair<K, V>>)

Process items in the map one at a time. This is similar to reset but instead of handling the content of the entire map it surfaces each item one at a time. The timeout is applied to each individual item rather than the entire map like it does in reset.

Link copied to clipboard
suspend fun reset(block: suspend (Map<K, V>) -> Map<K, V>)

Reset the content of the map entirely.

Link copied to clipboard
suspend fun set(key: K, block: suspend (V?) -> V?)

Set a value for the given key.

Link copied to clipboard
suspend fun size(): Int

Get the number of entries.