tuweni / org.apache.tuweni.kv / LevelDBKeyValueStore

LevelDBKeyValueStore

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

A key-value store backed by LevelDB.

Parameters

dbPath - The path to the levelDB 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

options - Options for the levelDB database.

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 LevelDB-backed key-value store.

LevelDBKeyValueStore(dbPath: Path, keySerializer: (K) -> Bytes, valueSerializer: (V) -> Bytes, keyDeserializer: (Bytes) -> K, valueDeserializer: (Bytes) -> V, options: Options = Options().createIfMissing(true).cacheSize((100 * 1048576).toLong()), 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 LevelDB 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 LevelDB-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>): LevelDBKeyValueStore<K, V>
fun <K, V> open(dbPath: Path, keySerializer: Function<K, Bytes>, valueSerializer: Function<V, Bytes>, keyDeserializer: Function<Bytes, K>, valueDeserializer: Function<Bytes, V>, options: Options): LevelDBKeyValueStore<K, V>

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

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