Class RedisMetadataStore
java.lang.Object
org.springframework.integration.redis.metadata.RedisMetadataStore
- All Implemented Interfaces:
ConcurrentMetadataStore,MetadataStore
public class RedisMetadataStore extends Object implements ConcurrentMetadataStore
Redis implementation of
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.
- Since:
- 3.0
- Author:
- Gunnar Hillert, Artem Bilan
-
Field Summary
-
Constructor Summary
Constructors Constructor Description RedisMetadataStore(RedisConnectionFactory connectionFactory)RedisMetadataStore(RedisConnectionFactory connectionFactory, String key)Initializes theRedisPropertiesby providedRedisConnectionFactoryand key.RedisMetadataStore(RedisOperations<String,?> operations)RedisMetadataStore(RedisOperations<String,?> operations, String key)Initializes theRedisPropertiesby providedRedisConnectionFactoryand key.RedisMetadataStore(RedisProperties properties)Specifies theRedisPropertiesbackend for thisConcurrentMetadataStore. -
Method Summary
Modifier and Type Method Description Stringget(String key)Retrieve the persisted value for the provided key.voidput(String key, String value)Persists the provided key and value to Redis.StringputIfAbsent(String key, String value)Atomically insert the key into the store.Stringremove(String key)Remove a value for the given key from this MetadataStore.booleanreplace(String key, String oldValue, String newValue)Atomically replace the value for the key in the store if the old value matches the oldValue argument.
-
Field Details
-
KEY
- See Also:
- Constant Field Values
-
-
Constructor Details
-
RedisMetadataStore
Specifies theRedisPropertiesbackend for thisConcurrentMetadataStore.- Parameters:
properties- The properties.
-
RedisMetadataStore
- Parameters:
connectionFactory- The connection factory.
-
RedisMetadataStore
Initializes theRedisPropertiesby providedRedisConnectionFactoryand key.- Parameters:
connectionFactory- The connection factory.key- The key.
-
RedisMetadataStore
- Parameters:
operations- The Redis operations object.
-
RedisMetadataStore
Initializes theRedisPropertiesby providedRedisConnectionFactoryand key.- Parameters:
operations- The Redis operations object.key- The key.
-
-
Method Details
-
put
Persists the provided key and value to Redis.- Specified by:
putin interfaceMetadataStore- Parameters:
key- Must not be nullvalue- Must not be null
-
get
Retrieve the persisted value for the provided key.- Specified by:
getin interfaceMetadataStore- Parameters:
key- Must not be null- Returns:
- The value.
-
remove
Description copied from interface:MetadataStoreRemove a value for the given key from this MetadataStore.- Specified by:
removein interfaceMetadataStore- Parameters:
key- The key.- Returns:
- The previous value associated with key, or null if there was no mapping for key.
-
putIfAbsent
Description copied from interface:ConcurrentMetadataStoreAtomically insert the key into the store.- Specified by:
putIfAbsentin interfaceConcurrentMetadataStore- Parameters:
key- The key.value- The value.- Returns:
- null if successful, the old value otherwise.
-
replace
Description copied from interface:ConcurrentMetadataStoreAtomically replace the value for the key in the store if the old value matches the oldValue argument.- Specified by:
replacein interfaceConcurrentMetadataStore- Parameters:
key- The key.oldValue- The old value.newValue- The new value.- Returns:
- true if successful.
-