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 theRedisProperties
by providedRedisConnectionFactory
and key.RedisMetadataStore(RedisOperations<String,?> operations)
RedisMetadataStore(RedisOperations<String,?> operations, String key)
Initializes theRedisProperties
by providedRedisConnectionFactory
and key.RedisMetadataStore(RedisProperties properties)
Specifies theRedisProperties
backend for thisConcurrentMetadataStore
. -
Method Summary
Modifier and Type Method 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.
-
Field Details
-
KEY
- See Also:
- Constant Field Values
-
-
Constructor Details
-
RedisMetadataStore
Specifies theRedisProperties
backend for thisConcurrentMetadataStore
.- Parameters:
properties
- The properties.
-
RedisMetadataStore
- Parameters:
connectionFactory
- The connection factory.
-
RedisMetadataStore
Initializes theRedisProperties
by providedRedisConnectionFactory
and key.- Parameters:
connectionFactory
- The connection factory.key
- The key.
-
RedisMetadataStore
- Parameters:
operations
- The Redis operations object.
-
RedisMetadataStore
Initializes theRedisProperties
by providedRedisConnectionFactory
and key.- Parameters:
operations
- The Redis operations object.key
- The key.
-
-
Method Details
-
put
Persists the provided key and value to Redis.- Specified by:
put
in interfaceMetadataStore
- Parameters:
key
- Must not be nullvalue
- Must not be null
-
get
Retrieve the persisted value for the provided key.- Specified by:
get
in interfaceMetadataStore
- Parameters:
key
- Must not be null- Returns:
- The value.
-
remove
Description copied from interface:MetadataStore
Remove a value for the given key from this MetadataStore.- Specified by:
remove
in 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:ConcurrentMetadataStore
Atomically insert the key into the store.- Specified by:
putIfAbsent
in interfaceConcurrentMetadataStore
- Parameters:
key
- The key.value
- The value.- Returns:
- null if successful, the old value otherwise.
-
replace
Description copied from interface:ConcurrentMetadataStore
Atomically replace the value for the key in the store if the old value matches the oldValue argument.- Specified by:
replace
in interfaceConcurrentMetadataStore
- Parameters:
key
- The key.oldValue
- The old value.newValue
- The new value.- Returns:
- true if successful.
-