Interface KeyValueStore<K,V>

Type Parameters:
K - the type of keys
V - the type of values
All Superinterfaces:
PStateStore, Store
All Known Subinterfaces:
DocumentStore<K>

public interface KeyValueStore<K,V> extends PStateStore
Simple typed persistent storage for key-value pairs. Stores are distributed, durable, and replicated. Key-value stores are created using AgentTopology.declareKeyValueStore(String, Class, Class).
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if the store contains the specified key.
    get(K key)
    Gets the value associated with the given key.
    getOrDefault(K key, V defaultValue)
    Gets the value associated with the given key, or returns a default value if not found.
    void
    put(K key, V value)
    Associates the specified value with the specified key.
    <T extends V, R>
    void
    update(K key, com.rpl.rama.ops.RamaFunction1<T,R> updateFunction)
    Updates the value associated with the given key using the provided function.

    Methods inherited from interface com.rpl.agentorama.store.PStateStore

    select, select, selectOne, selectOne, transform
  • Method Details

    • get

      V get(K key)
      Gets the value associated with the given key.
      Parameters:
      key - the key to look up
      Returns:
      the value associated with the key, or null if not found
    • getOrDefault

      V getOrDefault(K key, V defaultValue)
      Gets the value associated with the given key, or returns a default value if not found.
      Parameters:
      key - the key to look up
      defaultValue - the default value to return if key is not found
      Returns:
      the value associated with the key, or the default value if not found
    • put

      void put(K key, V value)
      Associates the specified value with the specified key.
      Parameters:
      key - the key
      value - the value to associate with the key
    • update

      <T extends V, R> void update(K key, com.rpl.rama.ops.RamaFunction1<T,R> updateFunction)
      Updates the value associated with the given key using the provided function.
      Parameters:
      key - the key to update
      updateFunction - function to apply to the current value
    • containsKey

      boolean containsKey(K key)
      Checks if the store contains the specified key.
      Parameters:
      key - the key to check
      Returns:
      true if the store contains the key, false otherwise