Class DefaultKeyValueStore
java.lang.Object
io.fluxzero.sdk.common.AbstractNamespaced<KeyValueStore>
io.fluxzero.sdk.persisting.keyvalue.DefaultKeyValueStore
- All Implemented Interfaces:
Namespaced<KeyValueStore>, KeyValueStore
public class DefaultKeyValueStore
extends AbstractNamespaced<KeyValueStore>
implements KeyValueStore
The default implementation of the
KeyValueStore interface that provides operations for storing, retrieving,
and deleting key-value pairs using a KeyValueClient and a Serializer. This class handles
serialization and deserialization of values and ensures that operations conform to the guarantees provided by the
client.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected KeyValueStorecreateForNamespace(String namespace) Removes a value asynchronously with the specified delivery guarantee.<R> RRetrieves the value associated with the given key.Stores a value under the given key with the specified delivery guarantee.storeIfAbsent(String key, Object value) Stores a value only if there is no existing value for the specified key.withDefaultGuarantee(Guarantee guarantee) Configures the concrete application delivery default before first use; namespace stores inherit it.Methods inherited from class AbstractNamespaced
close, forNamespaceMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface KeyValueStore
delete, forNamespace, storeMethods inherited from interface Namespaced
forApplicationNamespace, forDefaultNamespace
-
Constructor Details
-
DefaultKeyValueStore
-
-
Method Details
-
createForNamespace
- Specified by:
createForNamespacein classAbstractNamespaced<KeyValueStore>
-
store
Description copied from interface:KeyValueStoreStores a value under the given key with the specified delivery guarantee.- Specified by:
storein interfaceKeyValueStore- Parameters:
key- the key to store the value undervalue- the value to storeguarantee- the delivery guarantee (DEFAULT, NONE, SENT, or STORED)- Returns:
- completion according to the selected guarantee
-
storeIfAbsent
Description copied from interface:KeyValueStoreStores a value only if there is no existing value for the specified key. This always requests a stored result; the application delivery default does not weaken the conditional operation.- Specified by:
storeIfAbsentin interfaceKeyValueStore- Parameters:
key- the key to store the value undervalue- the value to store- Returns:
- a future with
trueif the value was stored,falseif the key already had a value
-
get
Description copied from interface:KeyValueStoreRetrieves the value associated with the given key.- Specified by:
getin interfaceKeyValueStore- Type Parameters:
R- the expected result type- Parameters:
key- the key to retrieve- Returns:
- the stored value, or
nullif not found
-
delete
Description copied from interface:KeyValueStoreRemoves a value asynchronously with the specified delivery guarantee.- Specified by:
deletein interfaceKeyValueStore- Parameters:
key- the key to deleteguarantee- concrete guarantee or DEFAULT- Returns:
- completion according to the selected guarantee
-
withDefaultGuarantee
Configures the concrete application delivery default before first use; namespace stores inherit it.
-