tuweni / org.apache.tuweni.kv / ProxyKeyValueStore

ProxyKeyValueStore

class ProxyKeyValueStore<K, V, E, R> : KeyValueStore<K, V> (source)

A store used as a proxy for another store.

For example, we may want to store rich objects and transform them to a lower-level form, or reuse the same store across multiple usages.

Parameters

store - the key/value store

unproxyKey - function to transform the key from the proxied store to the outer store

proxyKey - function to transform the key from this proxy to the proxied store

unproxyValue - function to transform the value from the proxied store to the outer store

proxyValue - function to transform the value from this proxy to the proxied store

coroutineContext - the kotlin coroutine context

Constructors

<init>

A store used as a proxy for another store.

ProxyKeyValueStore(store: KeyValueStore<E, R>, unproxyKey: (E) -> K, proxyKey: (K) -> E, unproxyValue: (R) -> V, proxyValue: (K, V) -> R, coroutineContext: CoroutineContext = store.coroutineContext)

Properties

coroutineContext

the kotlin coroutine context

val coroutineContext: CoroutineContext

Functions

clear

Clears the contents of the store.

suspend fun clear(): Unit

close

Close the store

fun close(): Unit

containsKey

Returns true if the store contains the key.

suspend fun containsKey(key: K): Boolean

get

Retrieves data from the store.

suspend fun get(key: K): V?

keys

Provides an iterator over the keys of the store.

suspend fun keys(): Iterable<K>

put

Puts data into the store.

suspend fun put(key: K, value: V): Unit

Companion Object Functions

open

Opens a proxy store.

fun <K, V, E, R> open(store: KeyValueStore<E, R>, unproxyKey: Function<E, K>, proxyKey: Function<K, E>, unproxyValue: Function<R, V>, proxyValue: BiFunction<K, V, R>): ProxyKeyValueStore<K, V, E, R>