Class InMemoryKeyValueClient

java.lang.Object
io.fluxcapacitor.javaclient.persisting.keyvalue.client.InMemoryKeyValueClient
All Implemented Interfaces:
KeyValueClient, AutoCloseable

public class InMemoryKeyValueClient extends Object implements KeyValueClient
  • Constructor Details

    • InMemoryKeyValueClient

      public InMemoryKeyValueClient()
    • InMemoryKeyValueClient

      protected InMemoryKeyValueClient(Map<String,Data<byte[]>> map)
  • Method Details

    • putValue

      public Awaitable putValue(String key, Data<byte[]> value, Guarantee guarantee)
      Description copied from interface: KeyValueClient
      Adds or replaces the given value in the key value store.
      Specified by:
      putValue in interface KeyValueClient
      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

      public CompletableFuture<Boolean> putValueIfAbsent(String key, Data<byte[]> value)
      Description copied from interface: KeyValueClient
      Adds the given value in the key value store if the key is not already mapped to a value.
      Specified by:
      putValueIfAbsent in interface KeyValueClient
      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

      public Data<byte[]> getValue(String key)
      Description copied from interface: KeyValueClient
      Returns the Data object associated with the given key. Returns null if there is no associated value.
      Specified by:
      getValue in interface KeyValueClient
      Parameters:
      key - The key associated with the value
      Returns:
      the value for the given key or null
    • deleteValue

      public Awaitable deleteValue(String key)
      Description copied from interface: KeyValueClient
      Deletes the value associated with the given key.
      Specified by:
      deleteValue in interface KeyValueClient
      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

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface KeyValueClient