K
- the Redis key type against which the template works (usually a String)V
- the Redis value type against which the template workspublic class ReactiveRedisTemplate<K,V> extends Object implements ReactiveRedisOperations<K,V>
ReactiveRedisOperations
.
Performs automatic serialization/deserialization between the given objects and the underlying binary data in the
Redis store.
Note that while the template is generified, it is up to the serializers/deserializers to properly convert the given
Objects to and from binary data.Constructor and Description |
---|
ReactiveRedisTemplate(ReactiveRedisConnectionFactory connectionFactory,
RedisSerializationContext<K,V> serializationContext)
Creates new
ReactiveRedisTemplate using given ReactiveRedisConnectionFactory and
RedisSerializationContext . |
ReactiveRedisTemplate(ReactiveRedisConnectionFactory connectionFactory,
RedisSerializationContext<K,V> serializationContext,
boolean exposeConnection)
Creates new
ReactiveRedisTemplate using given ReactiveRedisConnectionFactory and
RedisSerializationContext . |
Modifier and Type | Method and Description |
---|---|
<T> reactor.core.publisher.Flux<T> |
createFlux(ReactiveRedisCallback<T> callback)
Create a reusable Flux for a
ReactiveRedisCallback . |
<T> reactor.core.publisher.Mono<T> |
createMono(ReactiveRedisCallback<T> callback)
Create a reusable Mono for a
ReactiveRedisCallback . |
protected ReactiveRedisConnection |
createRedisConnectionProxy(ReactiveRedisConnection reactiveRedisConnection) |
reactor.core.publisher.Mono<Long> |
delete(K... keys)
Delete given
key . |
reactor.core.publisher.Mono<Long> |
delete(org.reactivestreams.Publisher<K> keys)
Delete given
keys . |
<T> reactor.core.publisher.Flux<T> |
execute(ReactiveRedisCallback<T> action)
Executes the given action within a Redis connection.
|
<T> reactor.core.publisher.Flux<T> |
execute(ReactiveRedisCallback<T> action,
boolean exposeConnection)
Executes the given action object within a connection that can be exposed or not.
|
<T> reactor.core.publisher.Flux<T> |
execute(RedisScript<T> script,
List<K> keys,
List<?> args)
Executes the given
RedisScript |
<T> reactor.core.publisher.Flux<T> |
execute(RedisScript<T> script,
List<K> keys,
List<?> args,
RedisElementWriter<?> argsWriter,
RedisElementReader<T> resultReader)
Executes the given
RedisScript , using the provided RedisSerializer s to serialize the script
arguments and result. |
reactor.core.publisher.Mono<Boolean> |
expire(K key,
Duration timeout)
Set time to live for given
key . |
reactor.core.publisher.Mono<Boolean> |
expireAt(K key,
Instant expireAt)
Set the expiration for given
key as a expireAt timestamp. |
ReactiveRedisConnectionFactory |
getConnectionFactory()
Returns the connectionFactory.
|
reactor.core.publisher.Mono<Duration> |
getExpire(K key)
Get the time to live for
key . |
RedisSerializationContext<K,V> |
getSerializationContext() |
reactor.core.publisher.Mono<Boolean> |
hasKey(K key)
Determine if given
key exists. |
reactor.core.publisher.Flux<K> |
keys(K pattern)
Find all keys matching the given
pattern . |
reactor.core.publisher.Mono<Boolean> |
move(K key,
int dbIndex)
Move given
key to database with index . |
ReactiveGeoOperations<K,V> |
opsForGeo()
Returns geospatial specific operations interface.
|
<K1,V1> ReactiveGeoOperations<K1,V1> |
opsForGeo(RedisSerializationContext<K1,V1> serializationContext)
Returns geospatial specific operations interface.
|
<HK,HV> ReactiveHashOperations<K,HK,HV> |
opsForHash()
Returns the operations performed on hash values.
|
<K1,HK,HV> ReactiveHashOperations<K1,HK,HV> |
opsForHash(RedisSerializationContext<K1,?> serializationContext)
Returns the operations performed on hash values given a
RedisSerializationContext . |
ReactiveHyperLogLogOperations<K,V> |
opsForHyperLogLog()
Returns the operations performed on multisets using HyperLogLog.
|
<K1,V1> ReactiveHyperLogLogOperations<K1,V1> |
opsForHyperLogLog(RedisSerializationContext<K1,V1> serializationContext)
Returns the operations performed on multisets using HyperLogLog given a
RedisSerializationContext . |
ReactiveListOperations<K,V> |
opsForList()
Returns the operations performed on list values.
|
<K1,V1> ReactiveListOperations<K1,V1> |
opsForList(RedisSerializationContext<K1,V1> serializationContext)
Returns the operations performed on list values given a
RedisSerializationContext . |
ReactiveSetOperations<K,V> |
opsForSet()
Returns the operations performed on set values.
|
<K1,V1> ReactiveSetOperations<K1,V1> |
opsForSet(RedisSerializationContext<K1,V1> serializationContext)
Returns the operations performed on set values given a
RedisSerializationContext . |
ReactiveValueOperations<K,V> |
opsForValue()
Returns the operations performed on simple values (or Strings in Redis terminology).
|
<K1,V1> ReactiveValueOperations<K1,V1> |
opsForValue(RedisSerializationContext<K1,V1> serializationContext)
Returns the operations performed on simple values (or Strings in Redis terminology) given a
RedisSerializationContext . |
ReactiveZSetOperations<K,V> |
opsForZSet()
Returns the operations performed on zset values (also known as sorted sets).
|
<K1,V1> ReactiveZSetOperations<K1,V1> |
opsForZSet(RedisSerializationContext<K1,V1> serializationContext)
Returns the operations performed on zset values (also known as sorted sets) given a
RedisSerializationContext . |
reactor.core.publisher.Mono<Boolean> |
persist(K key)
Remove the expiration from given
key . |
protected <T> org.reactivestreams.Publisher<T> |
postProcessResult(org.reactivestreams.Publisher<T> result,
ReactiveRedisConnection connection,
boolean existingConnection)
Processes the result before returning the
Publisher . |
protected ReactiveRedisConnection |
preProcessConnection(ReactiveRedisConnection connection,
boolean existingConnection)
Processes the connection (before any settings are executed on it).
|
reactor.core.publisher.Mono<K> |
randomKey()
Return a random key from the keyspace.
|
reactor.core.publisher.Mono<Boolean> |
rename(K oldKey,
K newKey)
Rename key
oldKey to newKey . |
reactor.core.publisher.Mono<Boolean> |
renameIfAbsent(K oldKey,
K newKey)
Rename key
oleName to newKey only if newKey does not exist. |
reactor.core.publisher.Mono<DataType> |
type(K key)
Determine the type stored at
key . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
execute, execute
public ReactiveRedisTemplate(ReactiveRedisConnectionFactory connectionFactory, RedisSerializationContext<K,V> serializationContext)
ReactiveRedisTemplate
using given ReactiveRedisConnectionFactory
and
RedisSerializationContext
.connectionFactory
- must not be null.serializationContext
- must not be null.public ReactiveRedisTemplate(ReactiveRedisConnectionFactory connectionFactory, RedisSerializationContext<K,V> serializationContext, boolean exposeConnection)
ReactiveRedisTemplate
using given ReactiveRedisConnectionFactory
and
RedisSerializationContext
.connectionFactory
- must not be null.serializationContext
- must not be null.exposeConnection
- flag indicating to expose the connection used.public ReactiveRedisConnectionFactory getConnectionFactory()
public <T> reactor.core.publisher.Flux<T> execute(ReactiveRedisCallback<T> action)
ReactiveRedisOperations
execute
in interface ReactiveRedisOperations<K,V>
T
- return typeaction
- callback object that specifies the Redis actionFlux.empty()
.public <T> reactor.core.publisher.Flux<T> execute(ReactiveRedisCallback<T> action, boolean exposeConnection)
T
- return typeaction
- callback object to executeexposeConnection
- whether to enforce exposure of the native Redis Connection to callback codepublic <T> reactor.core.publisher.Flux<T> createFlux(ReactiveRedisCallback<T> callback)
ReactiveRedisCallback
. Callback is executed within a connection context. The
connection is released outside the callback.callback
- must not be nullFlux
wrapping the ReactiveRedisCallback
.public <T> reactor.core.publisher.Mono<T> createMono(ReactiveRedisCallback<T> callback)
ReactiveRedisCallback
. Callback is executed within a connection context. The
connection is released outside the callback.callback
- must not be nullMono
wrapping the ReactiveRedisCallback
.public reactor.core.publisher.Mono<Boolean> hasKey(K key)
ReactiveRedisOperations
key
exists.hasKey
in interface ReactiveRedisOperations<K,V>
key
- must not be null.public reactor.core.publisher.Mono<DataType> type(K key)
ReactiveRedisOperations
key
.type
in interface ReactiveRedisOperations<K,V>
key
- must not be null.public reactor.core.publisher.Flux<K> keys(K pattern)
ReactiveRedisOperations
pattern
.keys
in interface ReactiveRedisOperations<K,V>
pattern
- must not be null.public reactor.core.publisher.Mono<K> randomKey()
ReactiveRedisOperations
randomKey
in interface ReactiveRedisOperations<K,V>
public reactor.core.publisher.Mono<Boolean> rename(K oldKey, K newKey)
ReactiveRedisOperations
oldKey
to newKey
.rename
in interface ReactiveRedisOperations<K,V>
oldKey
- must not be null.newKey
- must not be null.public reactor.core.publisher.Mono<Boolean> renameIfAbsent(K oldKey, K newKey)
ReactiveRedisOperations
oleName
to newKey
only if newKey
does not exist.renameIfAbsent
in interface ReactiveRedisOperations<K,V>
oldKey
- must not be null.newKey
- must not be null.@SafeVarargs public final reactor.core.publisher.Mono<Long> delete(K... keys)
ReactiveRedisOperations
key
.delete
in interface ReactiveRedisOperations<K,V>
keys
- must not be null.public reactor.core.publisher.Mono<Long> delete(org.reactivestreams.Publisher<K> keys)
ReactiveRedisOperations
keys
.delete
in interface ReactiveRedisOperations<K,V>
keys
- must not be null.public reactor.core.publisher.Mono<Boolean> expire(K key, Duration timeout)
ReactiveRedisOperations
key
.expire
in interface ReactiveRedisOperations<K,V>
key
- must not be null.timeout
- must not be null.public reactor.core.publisher.Mono<Boolean> expireAt(K key, Instant expireAt)
ReactiveRedisOperations
key
as a expireAt timestamp.expireAt
in interface ReactiveRedisOperations<K,V>
key
- must not be null.expireAt
- must not be null.public reactor.core.publisher.Mono<Boolean> persist(K key)
ReactiveRedisOperations
key
.persist
in interface ReactiveRedisOperations<K,V>
key
- must not be null.public reactor.core.publisher.Mono<Duration> getExpire(K key)
ReactiveRedisOperations
key
.getExpire
in interface ReactiveRedisOperations<K,V>
key
- must not be null.Duration
of the associated key. Duration.ZERO
if no timeout associated or empty
Mono
if the key does not exist.public reactor.core.publisher.Mono<Boolean> move(K key, int dbIndex)
ReactiveRedisOperations
key
to database with index
.move
in interface ReactiveRedisOperations<K,V>
key
- must not be null.public <T> reactor.core.publisher.Flux<T> execute(RedisScript<T> script, List<K> keys, List<?> args)
ReactiveRedisOperations
RedisScript
execute
in interface ReactiveRedisOperations<K,V>
script
- The script to execute. Must not be null.keys
- keys that need to be passed to the script. Must not be null.args
- args that need to be passed to the script. Must not be null.Flux.empty()
if RedisScript.getResultType()
is null,
likely indicating a throw-away status reply (i.e. "OK").public <T> reactor.core.publisher.Flux<T> execute(RedisScript<T> script, List<K> keys, List<?> args, RedisElementWriter<?> argsWriter, RedisElementReader<T> resultReader)
ReactiveRedisOperations
RedisScript
, using the provided RedisSerializer
s to serialize the script
arguments and result.execute
in interface ReactiveRedisOperations<K,V>
script
- The script to executekeys
- keys that need to be passed to the script.args
- args that need to be passed to the script.argsWriter
- The RedisElementWriter
to use for serializing argsresultReader
- The RedisElementReader
to use for serializing the script return valueFlux.empty()
if RedisScript.getResultType()
is null,
likely indicating a throw-away status reply (i.e. "OK").protected ReactiveRedisConnection preProcessConnection(ReactiveRedisConnection connection, boolean existingConnection)
connection
- must not be null.existingConnection
- protected <T> org.reactivestreams.Publisher<T> postProcessResult(org.reactivestreams.Publisher<T> result, ReactiveRedisConnection connection, boolean existingConnection)
Publisher
. Default implementation returns the result as is.result
- must not be null.connection
- must not be null.existingConnection
- protected ReactiveRedisConnection createRedisConnectionProxy(ReactiveRedisConnection reactiveRedisConnection)
public ReactiveGeoOperations<K,V> opsForGeo()
ReactiveRedisOperations
opsForGeo
in interface ReactiveRedisOperations<K,V>
public <K1,V1> ReactiveGeoOperations<K1,V1> opsForGeo(RedisSerializationContext<K1,V1> serializationContext)
ReactiveRedisOperations
opsForGeo
in interface ReactiveRedisOperations<K,V>
serializationContext
- serializers to be used with the returned operations, must not be null.public <HK,HV> ReactiveHashOperations<K,HK,HV> opsForHash()
ReactiveRedisOperations
opsForHash
in interface ReactiveRedisOperations<K,V>
HK
- hash key (or field) type.HV
- hash value type.public <K1,HK,HV> ReactiveHashOperations<K1,HK,HV> opsForHash(RedisSerializationContext<K1,?> serializationContext)
ReactiveRedisOperations
RedisSerializationContext
.opsForHash
in interface ReactiveRedisOperations<K,V>
HK
- hash key (or field) type.HV
- hash value type.serializationContext
- serializers to be used with the returned operations, must not be null.public ReactiveHyperLogLogOperations<K,V> opsForHyperLogLog()
ReactiveRedisOperations
opsForHyperLogLog
in interface ReactiveRedisOperations<K,V>
public <K1,V1> ReactiveHyperLogLogOperations<K1,V1> opsForHyperLogLog(RedisSerializationContext<K1,V1> serializationContext)
ReactiveRedisOperations
RedisSerializationContext
.opsForHyperLogLog
in interface ReactiveRedisOperations<K,V>
serializationContext
- serializers to be used with the returned operations, must not be null.public ReactiveListOperations<K,V> opsForList()
ReactiveRedisOperations
opsForList
in interface ReactiveRedisOperations<K,V>
public <K1,V1> ReactiveListOperations<K1,V1> opsForList(RedisSerializationContext<K1,V1> serializationContext)
ReactiveRedisOperations
RedisSerializationContext
.opsForList
in interface ReactiveRedisOperations<K,V>
serializationContext
- serializers to be used with the returned operations, must not be null.public ReactiveSetOperations<K,V> opsForSet()
ReactiveRedisOperations
opsForSet
in interface ReactiveRedisOperations<K,V>
public <K1,V1> ReactiveSetOperations<K1,V1> opsForSet(RedisSerializationContext<K1,V1> serializationContext)
ReactiveRedisOperations
RedisSerializationContext
.opsForSet
in interface ReactiveRedisOperations<K,V>
serializationContext
- serializers to be used with the returned operations, must not be null.public ReactiveValueOperations<K,V> opsForValue()
ReactiveRedisOperations
opsForValue
in interface ReactiveRedisOperations<K,V>
public <K1,V1> ReactiveValueOperations<K1,V1> opsForValue(RedisSerializationContext<K1,V1> serializationContext)
ReactiveRedisOperations
RedisSerializationContext
.opsForValue
in interface ReactiveRedisOperations<K,V>
serializationContext
- serializers to be used with the returned operations, must not be null.public ReactiveZSetOperations<K,V> opsForZSet()
ReactiveRedisOperations
opsForZSet
in interface ReactiveRedisOperations<K,V>
public <K1,V1> ReactiveZSetOperations<K1,V1> opsForZSet(RedisSerializationContext<K1,V1> serializationContext)
ReactiveRedisOperations
RedisSerializationContext
.opsForZSet
in interface ReactiveRedisOperations<K,V>
serializationContext
- serializers to be used with the returned operations, must not be null.public RedisSerializationContext<K,V> getSerializationContext()
getSerializationContext
in interface ReactiveRedisOperations<K,V>
RedisSerializationContext
.Copyright © 2011–2018 Pivotal Software, Inc.. All rights reserved.