Interface KeyValueClient

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
InMemoryKeyValueStore, WebsocketKeyValueClient

public interface KeyValueClient extends AutoCloseable
Represents a service to store and retrieve a piece of serialized data by key.
  • Method Details

    • putValue

      CompletableFuture<Void> 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 value
      value - The value to store
      guarantee - 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 value
      value - 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 the Data object associated with the given key. Returns null if there is no associated value.
      Parameters:
      key - The key associated with the value
      Returns:
      the value for the given key or null
    • deleteValue

      default CompletableFuture<Void> 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
    • deleteValue

      CompletableFuture<Void> deleteValue(String key, Guarantee guarantee)
      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:
      close in interface AutoCloseable