Package com.rpl.agentorama.store
Interface KeyValueStore<K,V>
- Type Parameters:
K- the type of keysV- the type of values
- All Superinterfaces:
PStateStore,Store
- All Known Subinterfaces:
DocumentStore<K>
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 TypeMethodDescriptionbooleancontainsKey(K key) Checks if the store contains the specified 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.voidAssociates the specified value with the specified key.<T extends V,R>
voidUpdates the value associated with the given key using the provided function.
-
Method Details
-
get
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
Gets the value associated with the given key, or returns a default value if not found.- Parameters:
key- the key to look updefaultValue- 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
Associates the specified value with the specified key.- Parameters:
key- the keyvalue- the value to associate with the key
-
update
Updates the value associated with the given key using the provided function.- Parameters:
key- the key to updateupdateFunction- function to apply to the current value
-
containsKey
Checks if the store contains the specified key.- Parameters:
key- the key to check- Returns:
- true if the store contains the key, false otherwise
-