Package org.nuxeo.runtime.kv
Class AbstractKeyValueStoreProvider
java.lang.Object
org.nuxeo.runtime.kv.AbstractKeyValueStoreProvider
- All Implemented Interfaces:
KeyValueStore,KeyValueStoreProvider
- Direct Known Subclasses:
MemKeyValueStore,MongoDBKeyValueStore,SQLKeyValueStore
Key/Value Store common methods.
- Since:
- 9.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected static final ThreadLocal<CharsetDecoder> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongAtomically adds the delta to the value associated to the key, interpreted as a long represented as a string.protected static LongbytesToLong(byte[] bytes) Converts UTF-8 bytes to a Long, or throws if malformed.protected static StringbytesToString(byte[] bytes) Converts UTF-8 bytes to a String, or throws if malformed.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, 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.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.voidinitialize(KeyValueStoreDescriptor descriptor) Initializes this Key/Value store provider.protected static byte[]longToBytes(Long value) Converts a long to UTF-8 bytes.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.voidSets the value associated to the key, and a TTL.protected static byte[]stringToBytes(String string) Converts a String to UTF-8 bytes.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.nuxeo.runtime.kv.KeyValueStore
compareAndSet, get, put, remove, removeLong, removeString, setTTLMethods inherited from interface org.nuxeo.runtime.kv.KeyValueStoreProvider
clear, close, keyStream, keyStream
-
Field Details
-
name
-
UTF_8_DECODERS
-
-
Constructor Details
-
AbstractKeyValueStoreProvider
public AbstractKeyValueStoreProvider()
-
-
Method Details
-
initialize
Description copied from interface:KeyValueStoreProviderInitializes this Key/Value store provider.- Specified by:
initializein interfaceKeyValueStoreProvider- Parameters:
descriptor- the store provider descriptor
-
toString
-
bytesToString
Converts UTF-8 bytes to a String, or throws if malformed.- Throws:
CharacterCodingException
-
stringToBytes
Converts a String to UTF-8 bytes. -
bytesToLong
Converts UTF-8 bytes to a Long, or throws if malformed.- Throws:
NumberFormatException
-
longToBytes
Converts a long to UTF-8 bytes. -
put
Description copied from interface:KeyValueStoreSets the value associated to the key.- Specified by:
putin interfaceKeyValueStore- Parameters:
key- the keyvalue- the value, which may benull
-
put
Description copied from interface:KeyValueStoreSets the value associated to the key.- Specified by:
putin interfaceKeyValueStore- Parameters:
key- the keyvalue- the value, which may benull
-
put
Description copied from interface:KeyValueStoreSets the value associated to the key, and a TTL.- Specified by:
putin interfaceKeyValueStore- Parameters:
key- the keyvalue- the value, which may benullttl- the TTL, in seconds (0 for infinite)
-
put
Description copied from interface:KeyValueStoreSets the value associated to the key.- Specified by:
putin interfaceKeyValueStore- Parameters:
key- the keyvalue- the value, which may benull
-
put
Description copied from interface:KeyValueStoreSets the value associated to the key.- Specified by:
putin interfaceKeyValueStore- Parameters:
key- the keyvalue- the value, which may benullttl- the TTL, in seconds (0 for infinite)
-
getString
Description copied from interface:KeyValueStoreRetrieves the value associated to the key.- Specified by:
getStringin interfaceKeyValueStore- Parameters:
key- the key- Returns:
- the value, or
nullif there is no value
-
getLong
Description copied from interface:KeyValueStoreRetrieves the value associated to the key.- Specified by:
getLongin interfaceKeyValueStore- Parameters:
key- the key- Returns:
- the value, or
nullif there is no value - Throws:
NumberFormatException- if the value cannot be returned as aLong
-
get
Description copied from interface:KeyValueStoreRetrieves the key/value map associated with the keys.- Specified by:
getin interfaceKeyValueStore- Parameters:
keys- the keys- Returns:
- the key/value map
-
getStrings
Description copied from interface:KeyValueStoreRetrieves the key/value map associated with the keys.- Specified by:
getStringsin interfaceKeyValueStore- Parameters:
keys- the keys- Returns:
- the key/value map
-
getLongs
Description copied from interface:KeyValueStoreRetrieves the key/value map associated with the keys.- Specified by:
getLongsin interfaceKeyValueStore- Parameters:
keys- the keys- Returns:
- the key/value map
- Throws:
NumberFormatException- if one of the values cannot be returned as aLong
-
compareAndSet
Description copied from interface:KeyValueStoreAtomically 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.
- Specified by:
compareAndSetin interfaceKeyValueStore- 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
Description copied from interface:KeyValueStoreAtomically 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.
- Specified by:
compareAndSetin interfaceKeyValueStore- 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
Description copied from interface:KeyValueStoreAtomically 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.
- Specified by:
compareAndSetin interfaceKeyValueStore- 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)
-
addAndGet
Description copied from interface:KeyValueStoreAtomically 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
KeyValueStore.get(java.lang.String)would returnnull), it is interpreted as0.- Specified by:
addAndGetin interfaceKeyValueStore- Parameters:
key- the keydelta- the delta to add- Returns:
- the new value
- Throws:
NumberFormatException- if the existing value cannot be interpreted as along
-