tuweni / org.apache.tuweni.kv / MapDBKeyValueStore

MapDBKeyValueStore

class MapDBKeyValueStore<K, V> : KeyValueStore<K, V> (source)

A key-value store backed by a MapDB instance.

Parameters

dbPath - The path to the MapDB database.

keySerializer - the serializer of key objects to bytes

valueSerializer - the serializer of value objects to bytes

keyDeserializer - the deserializer of keys from bytes

valueDeserializer - the deserializer of values from bytes

coroutineContext - The co-routine context for blocking tasks.

Exceptions

IOException - If an I/O error occurs.

Return
A key-value store.

Constructors

<init>

Open a MapDB-backed key-value store.

MapDBKeyValueStore(dbPath: Path, keySerializer: (K) -> Bytes, valueSerializer: (V) -> Bytes, keyDeserializer: (Bytes) -> K, valueDeserializer: (Bytes) -> V, coroutineContext: CoroutineContext = Dispatchers.IO)

Properties

coroutineContext

The co-routine context for blocking tasks.

val coroutineContext: CoroutineContext

Functions

clear

Clears the contents of the store.

suspend fun clear(): Unit

close

Closes the underlying MapDB instance.

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

Open a MapDB-backed key-value store.

fun <K, V> open(dbPath: Path, keySerializer: Function<K, Bytes>, valueSerializer: Function<V, Bytes>, keyDeserializer: Function<Bytes, K>, valueDeserializer: Function<Bytes, V>): MapDBKeyValueStore<K, V>

Open a MapDB-backed key-value store using Bytes keys and values.

fun open(dbPath: Path): MapDBKeyValueStore<Bytes, Bytes>