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, wait
clear, close, initialize, keyStream
compareAndSet, get, put, setTTL
protected static final ThreadLocal<CharsetDecoder> UTF_8_DECODERS
public AbstractKeyValueStoreProvider()
protected static String bytesToString(byte[] bytes) throws CharacterCodingException
CharacterCodingException
protected static byte[] stringToBytes(String string)
public void put(String key, byte[] value)
KeyValueStore
put
in interface KeyValueStore
key
- the keyvalue
- the value, which may be null
public void put(String key, String value)
KeyValueStore
put
in interface KeyValueStore
key
- the keyvalue
- the value, which may be null
public void put(String key, String value, long ttl)
KeyValueStore
put
in interface KeyValueStore
key
- the keyvalue
- the value, which may be null
ttl
- the TTL, in seconds (0 for infinite)public String getString(String key)
KeyValueStore
getString
in interface KeyValueStore
key
- the keynull
if there is no valuepublic Map<String,byte[]> get(Collection<String> keys)
KeyValueStore
get
in interface KeyValueStore
keys
- the keyspublic Map<String,String> getStrings(Collection<String> keys)
KeyValueStore
getStrings
in interface KeyValueStore
keys
- the keyspublic boolean compareAndSet(String key, byte[] expected, byte[] value)
KeyValueStore
Note value comparison is done by value and not by reference.
compareAndSet
in interface KeyValueStore
key
- the keyexpected
- the expected value, which may be null
value
- the updated value, which may be null
true
if the value was updated, or false
if not (the expected value was not found)public boolean compareAndSet(String key, String expected, String value)
KeyValueStore
Note value comparison is done by value and not by reference.
compareAndSet
in interface KeyValueStore
key
- the keyexpected
- the expected value, which may be null
value
- the updated value, which may be null
true
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)
KeyValueStore
Note value comparison is done by value and not by reference.
compareAndSet
in interface KeyValueStore
key
- the keyexpected
- the expected value, which may be null
value
- the updated value, which may be null
ttl
- 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.