public abstract class AbstractKeyValueStoreProvider extends Object implements KeyValueStoreProvider
| Modifier and Type | Field and Description |
|---|---|
protected static ThreadLocal<CharsetDecoder> |
UTF_8_DECODERS |
| Constructor and Description |
|---|
AbstractKeyValueStoreProvider() |
| Modifier and Type | Method and Description |
|---|---|
protected static String |
bytesToString(byte[] bytes)
Converts UTF-8 bytes to a String, or throws if malformed.
|
boolean |
compareAndSet(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.
|
boolean |
compareAndSet(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.
|
boolean |
compareAndSet(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.
|
Map<String,byte[]> |
get(Collection<String> keys)
Retrieves the key/value map associated with the keys.
|
String |
getString(String key)
Retrieves the value associated to the key.
|
Map<String,String> |
getStrings(Collection<String> keys)
Retrieves the key/value map associated with the keys.
|
void |
put(String key,
byte[] value)
Sets the value associated to the key.
|
void |
put(String key,
String value)
Sets the value associated to the key.
|
void |
put(String key,
String value,
long ttl)
Sets the value associated to the key, and a TTL.
|
protected static byte[] |
stringToBytes(String string)
Converts a String to UTF-8 bytes.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclear, close, initialize, keyStreamcompareAndSet, get, put, setTTLprotected static final ThreadLocal<CharsetDecoder> UTF_8_DECODERS
public AbstractKeyValueStoreProvider()
protected static String bytesToString(byte[] bytes) throws CharacterCodingException
CharacterCodingExceptionprotected static byte[] stringToBytes(String string)
public void put(String key, byte[] value)
KeyValueStoreput in interface KeyValueStorekey - the keyvalue - the value, which may be nullpublic void put(String key, String value)
KeyValueStoreput in interface KeyValueStorekey - the keyvalue - the value, which may be nullpublic void put(String key, String value, long ttl)
KeyValueStoreput in interface KeyValueStorekey - the keyvalue - the value, which may be nullttl - the TTL, in seconds (0 for infinite)public String getString(String key)
KeyValueStoregetString in interface KeyValueStorekey - the keynull if there is no valuepublic Map<String,byte[]> get(Collection<String> keys)
KeyValueStoreget in interface KeyValueStorekeys - the keyspublic Map<String,String> getStrings(Collection<String> keys)
KeyValueStoregetStrings in interface KeyValueStorekeys - the keyspublic boolean compareAndSet(String key, byte[] expected, byte[] value)
KeyValueStoreNote value comparison is done by value and not by reference.
compareAndSet in interface KeyValueStorekey - the keyexpected - the expected value, which may be nullvalue - the updated value, which may be nulltrue if the value was updated, or false if not (the expected value was not found)public boolean compareAndSet(String key, String expected, String value)
KeyValueStoreNote value comparison is done by value and not by reference.
compareAndSet in interface KeyValueStorekey - the keyexpected - the expected value, which may be nullvalue - the updated value, which may be nulltrue if the value was updated, or false if not (the expected value was not found)public boolean compareAndSet(String key, String expected, String value, long ttl)
KeyValueStoreNote value comparison is done by value and not by reference.
compareAndSet in interface KeyValueStorekey - the keyexpected - the expected value, which may be nullvalue - the updated value, which may be nullttl - the TTL, in seconds (0 for infinite)true if the value was updated, or false if not (the expected value was not found)Copyright © 2018 Nuxeo. All rights reserved.