tuweni / org.apache.tuweni.kv / EntityManagerKeyValueStore

EntityManagerKeyValueStore

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

JPA-backed key value store.

Parameters

entityClass - the class of entity to store

entityManagerProvider - the provider of entity managers to interact with JPA

idAccessor - the ID accessor

coroutineContext - the kotlin coroutine context.

Constructors

<init>

JPA-backed key value store.

EntityManagerKeyValueStore(entityManagerProvider: () -> EntityManager, entityClass: Class<V>, idAccessor: (V) -> K, coroutineContext: CoroutineContext = Dispatchers.IO)

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

Convenience method to put a record directly

suspend fun put(value: V): Unit

Puts data into the store.

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

Companion Object Functions

open

Open a relational database backed key-value store using a JPA entity manager.

fun <K, V> open(entityManagerProvider: Supplier<EntityManager>, entityClass: Class<V>, idAccessor: Function<V, K>): EntityManagerKeyValueStore<K, V>