public class RedisKeyValueStore extends AbstractKeyValueStoreProvider
The following configuration properties are available:
<namespace>
element instead.
Modifier and Type | Field and Description |
---|---|
protected byte[] |
compareAndDelSHA |
protected byte[] |
compareAndSetSHA |
protected byte[] |
compareNullAndSetSHA |
protected String |
namespace |
static String |
NAMESPACE_PROP
Deprecated.
since 10.10
|
protected static Long |
ONE |
name, UTF_8_DECODERS
Constructor and Description |
---|
RedisKeyValueStore() |
Modifier and Type | Method and Description |
---|---|
long |
addAndGet(String key,
long delta)
Atomically adds the delta to the value associated to the key, interpreted as a long represented as a string.
|
void |
clear()
Clears the content of this Key/Value store provider.
|
void |
close()
Closes this Key/Value store provider.
|
boolean |
compareAndSet(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.
|
static String |
ecapeGlob(String prefix)
Escape glob-like wildcards and [] char ranges with a backslash.
|
Map<String,byte[]> |
get(Collection<String> keys)
Retrieves the key/value map associated with the keys.
|
byte[] |
get(String key)
Retrieves the value associated to the key.
|
protected static byte[] |
getBytes(String key) |
Map<String,Long> |
getLongs(Collection<String> keys)
Retrieves the key/value map associated with the keys.
|
protected String[] |
getNamespace(KeyValueStoreDescriptor descriptor) |
Map<String,String> |
getStrings(Collection<String> keys)
Retrieves the key/value map associated with the keys.
|
protected List<byte[]> |
getValuesForKeys(Collection<String> keys) |
void |
initialize(KeyValueStoreDescriptor descriptor)
Initializes this Key/Value store provider.
|
Stream<String> |
keyStream()
Returns a
Stream of the keys contained in this Key/Value store provider. |
Stream<String> |
keyStream(String prefix)
Returns a
Stream of the keys with the given prefix contained in this Key/Value store provider. |
void |
put(String key,
byte[] value,
long ttl)
Sets the value associated to the key, and a TTL.
|
boolean |
setTTL(String key,
long ttl)
Sets the TTL for an existing key.
|
bytesToLong, bytesToString, compareAndSet, compareAndSet, compareAndSet, getLong, getString, longToBytes, put, put, put, put, put, stringToBytes, toString
@Deprecated public static final String NAMESPACE_PROP
protected byte[] compareAndSetSHA
protected byte[] compareAndDelSHA
protected byte[] compareNullAndSetSHA
public RedisKeyValueStore()
public void initialize(KeyValueStoreDescriptor descriptor)
KeyValueStoreProvider
initialize
in interface KeyValueStoreProvider
initialize
in class AbstractKeyValueStoreProvider
descriptor
- the store provider descriptorprotected String[] getNamespace(KeyValueStoreDescriptor descriptor)
public Stream<String> keyStream()
KeyValueStoreProvider
Stream
of the keys contained in this Key/Value store provider.
This operation may be slow and should only be used for management or debug purposes.
public Stream<String> keyStream(String prefix)
KeyValueStoreProvider
Stream
of the keys with the given prefix contained in this Key/Value store provider.
This operation may be slow and should only be used for management or debug purposes.
public static String ecapeGlob(String prefix)
public void close()
KeyValueStoreProvider
public void clear()
KeyValueStoreProvider
public void put(String key, byte[] value, long ttl)
KeyValueStore
key
- the keyvalue
- the value, which may be null
ttl
- the TTL, in seconds (0 for infinite)public byte[] get(String key)
KeyValueStore
key
- the keynull
if there is no valuepublic Map<String,byte[]> get(Collection<String> keys)
KeyValueStore
get
in interface KeyValueStore
get
in class AbstractKeyValueStoreProvider
keys
- the keyspublic Map<String,String> getStrings(Collection<String> keys)
KeyValueStore
getStrings
in interface KeyValueStore
getStrings
in class AbstractKeyValueStoreProvider
keys
- the keyspublic Map<String,Long> getLongs(Collection<String> keys)
KeyValueStore
getLongs
in interface KeyValueStore
getLongs
in class AbstractKeyValueStoreProvider
keys
- the keysprotected List<byte[]> getValuesForKeys(Collection<String> keys)
public boolean setTTL(String key, long ttl)
KeyValueStore
key
- the keyttl
- the TTL, in seconds (0 for infinite)true
if the TTL has been set, or false
if the key does not existpublic boolean compareAndSet(String key, byte[] expected, byte[] value, long ttl)
KeyValueStore
Note value comparison is done by value and not by reference.
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)public long addAndGet(String key, long delta) throws NumberFormatException
KeyValueStore
If the value does not exist (if KeyValueStore.get(java.lang.String)
would return null
), it is interpreted as 0
.
addAndGet
in interface KeyValueStore
addAndGet
in class AbstractKeyValueStoreProvider
key
- the keydelta
- the delta to addNumberFormatException
- if the existing value cannot be interpreted as a long
Copyright © 2019 Nuxeo. All rights reserved.