Interface KeyValueClient
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
InMemoryKeyValueClient,WebsocketKeyValueClient
public interface KeyValueClient extends AutoCloseable
Represents a service to store and retrieve a piece of serialized data by key.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()AwaitabledeleteValue(String key)Deletes the value associated with the given key.Data<byte[]>getValue(String key)Returns theDataobject associated with the given key.AwaitableputValue(String key, Data<byte[]> value, Guarantee guarantee)Adds or replaces the given value in the key value store.CompletableFuture<Boolean>putValueIfAbsent(String key, Data<byte[]> value)Adds the given value in the key value store if the key is not already mapped to a value.
-
-
-
Method Detail
-
putValue
Awaitable putValue(String key, Data<byte[]> value, Guarantee guarantee)
Adds or replaces the given value in the key value store.- Parameters:
key- The key associated with this valuevalue- The value to storeguarantee- The guarantee for storing- Returns:
- a handle that enables clients to wait until the value was sent or stored depending on the guarantee
-
putValueIfAbsent
CompletableFuture<Boolean> putValueIfAbsent(String key, Data<byte[]> value)
Adds the given value in the key value store if the key is not already mapped to a value.- Parameters:
key- The key associated with this valuevalue- The value to store- Returns:
- a handle that enables clients to wait until the value was sent or stored depending on the guarantee
-
getValue
Data<byte[]> getValue(String key)
Returns theDataobject associated with the given key. Returnsnullif there is no associated value.- Parameters:
key- The key associated with the value- Returns:
- the value for the given key or null
-
deleteValue
Awaitable deleteValue(String key)
Deletes the value associated with the given key.- Parameters:
key- The key associated with this value- Returns:
- a handle that enables clients to wait until the command was safely sent to the store
-
close
void close()
- Specified by:
closein interfaceAutoCloseable
-
-