Package org.nuxeo.runtime.kv
Interface KeyValueStore
- All Known Subinterfaces:
KeyValueStoreProvider
- All Known Implementing Classes:
AbstractKeyValueStoreProvider,MemKeyValueStore,MongoDBKeyValueStore,SQLKeyValueStore
public interface KeyValueStore
Key/Value Store.
This is the interface for a Key/Value store, which stores simple values associated to keys.
A Key/Value store is thread-safe.
- Since:
- 9.1
-
Method Summary
Modifier and TypeMethodDescriptionlongAtomically adds the delta to the value associated to the key, interpreted as a long represented as a string.booleancompareAndSet(String key, byte[] expected, byte[] value) Atomically sets the value associated to the key to the given value if the current value is the expected value.booleancompareAndSet(String key, byte[] expected, byte[] value, long ttl) Atomically sets the value associated to the key to the given value, with the given TTL, if the current value is the expected value.booleancompareAndSet(String key, String expected, String value) Atomically sets the value associated to the key to the given value if the current value is the expected value.booleancompareAndSet(String key, String expected, String value, long ttl) Atomically sets the value associated to the key to the given value, with the given TTL, if the current value is the expected value.byte[]Retrieves the value associated to the key.get(Collection<String> keys) Retrieves the key/value map associated with the keys.Retrieves the value associated to the key.getLongs(Collection<String> keys) Retrieves the key/value map associated with the keys.Retrieves the value associated to the key.getStrings(Collection<String> keys) Retrieves the key/value map associated with the keys.voidSets the value associated to the key.voidSets the value associated to the key, and a TTL.voidSets the value associated to the key.voidSets the value associated to the key.voidSets the value associated to the key.voidSets the value associated to the key, and a TTL.default byte[]Retrieves and removes the value associated to the key.default LongremoveLong(String key) Retrieves and removes the value associated to the key.default StringremoveString(String key) Retrieves and removes the value associated to the key.booleanSets the TTL for an existing key.
-
Method Details
-
put
Sets the value associated to the key.- Parameters:
key- the keyvalue- the value, which may benull
-
put
Sets the value associated to the key.- Parameters:
key- the keyvalue- the value, which may benull- Since:
- 9.3
-
put
Sets the value associated to the key.- Parameters:
key- the keyvalue- the value, which may benull- Since:
- 10.2
-
put
Sets the value associated to the key, and a TTL.- Parameters:
key- the keyvalue- the value, which may benullttl- the TTL, in seconds (0 for infinite)- Since:
- 9.3
-
put
Sets the value associated to the key, and a TTL.- Parameters:
key- the keyvalue- the value, which may benullttl- the TTL, in seconds (0 for infinite)- Since:
- 9.3
-
put
Sets the value associated to the key.- Parameters:
key- the keyvalue- the value, which may benullttl- the TTL, in seconds (0 for infinite)- Since:
- 10.2
-
setTTL
Sets the TTL for an existing key.- Parameters:
key- the keyttl- the TTL, in seconds (0 for infinite)- Returns:
trueif the TTL has been set, orfalseif the key does not exist- Since:
- 9.3
-
get
Retrieves the value associated to the key.- Parameters:
key- the key- Returns:
- the value, or
nullif there is no value
-
getString
Retrieves the value associated to the key.- Parameters:
key- the key- Returns:
- the value, or
nullif there is no value - Throws:
IllegalArgumentException- if the value cannot be returned as aString- Since:
- 9.3
-
getLong
Retrieves the value associated to the key.- Parameters:
key- the key- Returns:
- the value, or
nullif there is no value - Throws:
NumberFormatException- if the value cannot be returned as aLong- Since:
- 10.2
-
remove
Retrieves and removes the value associated to the key.- Parameters:
key- the key- Returns:
- the value, or
nullif there is no value - Since:
- 2025.5
-
removeString
Retrieves and removes the value associated to the key.- Parameters:
key- the key- Returns:
- the value, or
nullif there is no value - Throws:
IllegalArgumentException- if the value cannot be returned as aString- Since:
- 2025.5
-
removeLong
Retrieves and removes the value associated to the key.- Parameters:
key- the key- Returns:
- the value, or
nullif there is no value - Throws:
NumberFormatException- if the value cannot be returned as aLong- Since:
- 2025.5
-
get
Retrieves the key/value map associated with the keys.- Parameters:
keys- the keys- Returns:
- the key/value map
- Since:
- 9.10
-
getStrings
Retrieves the key/value map associated with the keys.- Parameters:
keys- the keys- Returns:
- the key/value map
- Throws:
IllegalArgumentException- if one of the values cannot be returned as aString- Since:
- 9.10
-
getLongs
Retrieves the key/value map associated with the keys.- Parameters:
keys- the keys- Returns:
- the key/value map
- Throws:
NumberFormatException- if one of the values cannot be returned as aLong- Since:
- 10.2
-
compareAndSet
Atomically sets the value associated to the key to the given value if the current value is the expected value.Note value comparison is done by value and not by reference.
- Parameters:
key- the keyexpected- the expected value, which may benullvalue- the updated value, which may benull- Returns:
trueif the value was updated, orfalseif not (the expected value was not found)
-
compareAndSet
Atomically sets the value associated to the key to the given value, with the given TTL, if the current value is the expected value.Note value comparison is done by value and not by reference.
- Parameters:
key- the keyexpected- the expected value, which may benullvalue- the updated value, which may benullttl- the TTL, in seconds (0 for infinite)- Returns:
trueif the value was updated, orfalseif not (the expected value was not found)- Since:
- 9.3
-
compareAndSet
Atomically sets the value associated to the key to the given value if the current value is the expected value.Note value comparison is done by value and not by reference.
- Parameters:
key- the keyexpected- the expected value, which may benullvalue- the updated value, which may benull- Returns:
trueif the value was updated, orfalseif not (the expected value was not found)- Since:
- 9.3
-
compareAndSet
Atomically sets the value associated to the key to the given value, with the given TTL, if the current value is the expected value.Note value comparison is done by value and not by reference.
- Parameters:
key- the keyexpected- the expected value, which may benullvalue- the updated value, which may benullttl- the TTL, in seconds (0 for infinite)- Returns:
trueif the value was updated, orfalseif not (the expected value was not found)- Since:
- 9.3
-
addAndGet
Atomically adds the delta to the value associated to the key, interpreted as a long represented as a string.If the value does not exist (if
get(java.lang.String)would returnnull), it is interpreted as0.- Parameters:
key- the keydelta- the delta to add- Returns:
- the new value
- Throws:
NumberFormatException- if the existing value cannot be interpreted as along- Since:
- 10.2
-