public class RedisMetadataStore extends Object implements ConcurrentMetadataStore
ConcurrentMetadataStore. Use this
ConcurrentMetadataStore to achieve meta-data persistence across application
restarts.
This implementation is based on the RedisProperties and its
replace(String, String, String); it can't currently be used with a Redis
cluster because the WATCH command is not supported.
| Constructor and Description |
|---|
RedisMetadataStore(RedisConnectionFactory connectionFactory)
|
RedisMetadataStore(RedisConnectionFactory connectionFactory,
String key)
Initializes the
RedisProperties by provided RedisConnectionFactory and key. |
RedisMetadataStore(RedisOperations<String,?> operations)
|
RedisMetadataStore(RedisOperations<String,?> operations,
String key)
Initializes the
RedisProperties by provided RedisConnectionFactory and key. |
RedisMetadataStore(RedisProperties properties)
Specifies the
RedisProperties backend for this ConcurrentMetadataStore. |
| Modifier and Type | Method and Description |
|---|---|
String |
get(String key)
Retrieve the persisted value for the provided key.
|
void |
put(String key,
String value)
Persists the provided key and value to Redis.
|
String |
putIfAbsent(String key,
String value)
Atomically insert the key into the store.
|
String |
remove(String key)
Remove a value for the given key from this MetadataStore.
|
boolean |
replace(String key,
String oldValue,
String newValue)
Atomically replace the value for the key in the store if the old
value matches the oldValue argument.
|
public static final String KEY
public RedisMetadataStore(RedisProperties properties)
RedisProperties backend for this ConcurrentMetadataStore.properties - The properties.public RedisMetadataStore(RedisConnectionFactory connectionFactory)
connectionFactory - The connection factory.public RedisMetadataStore(RedisConnectionFactory connectionFactory, String key)
RedisProperties by provided RedisConnectionFactory and key.connectionFactory - The connection factory.key - The key.public RedisMetadataStore(RedisOperations<String,?> operations)
operations - The Redis operations object.public RedisMetadataStore(RedisOperations<String,?> operations, String key)
RedisProperties by provided RedisConnectionFactory and key.operations - The Redis operations object.key - The key.public void put(String key, String value)
put in interface MetadataStorekey - Must not be nullvalue - Must not be nullpublic String get(String key)
get in interface MetadataStorekey - Must not be nullpublic String remove(String key)
MetadataStoreremove in interface MetadataStorekey - The key.public String putIfAbsent(String key, String value)
ConcurrentMetadataStoreputIfAbsent in interface ConcurrentMetadataStorekey - The key.value - The value.public boolean replace(String key, String oldValue, String newValue)
ConcurrentMetadataStorereplace in interface ConcurrentMetadataStorekey - The key.oldValue - The old value.newValue - The new value.