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 |
|---|---|
reactor.core.publisher.Mono<Long> |
convertAndSend(String destination,
V message)
Publishes the given message to the given channel.
|
<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 RedisSerializers 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.Flux<? extends ReactiveSubscription.Message<String,V>> |
listenTo(Topic... topics)
|
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. |
<HK,HV> ReactiveStreamOperations<K,HK,HV> |
opsForStream()
Returns the operations performed on streams.
|
<HK,HV> ReactiveStreamOperations<K,HK,HV> |
opsForStream(HashMapper<? super K,? super HK,? super HV> hashMapper)
Returns the operations performed on streams.
|
<HK,HV> ReactiveStreamOperations<K,HK,HV> |
opsForStream(RedisSerializationContext<K,?> serializationContext)
Returns the operations performed on streams given a
RedisSerializationContext. |
protected <HK,HV> ReactiveStreamOperations<K,HK,HV> |
opsForStream(RedisSerializationContext<K,?> serializationContext,
HashMapper<? super K,? super HK,? super HV> hashMapper) |
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.Flux<K> |
scan(ScanOptions options)
Use a
Flux to iterate over keys. |
reactor.core.publisher.Mono<DataType> |
type(K key)
Determine the type stored at
key. |
reactor.core.publisher.Mono<Long> |
unlink(K... keys)
Unlink the
key from the keyspace. |
reactor.core.publisher.Mono<Long> |
unlink(org.reactivestreams.Publisher<K> keys)
Unlink the
keys from the keyspace. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexecute, execute, listenToChannel, listenToPattern, scanpublic 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)
ReactiveRedisOperationsexecute 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<Long> convertAndSend(String destination, V message)
ReactiveRedisOperationsconvertAndSend in interface ReactiveRedisOperations<K,V>destination - the channel to publish to, must not be null nor empty.message - message to publish. Must not be null.public reactor.core.publisher.Flux<? extends ReactiveSubscription.Message<String,V>> listenTo(Topic... topics)
ReactiveRedisOperationslistenTo in interface ReactiveRedisOperations<K,V>topics - must not be null.messages.public reactor.core.publisher.Mono<Boolean> hasKey(K key)
ReactiveRedisOperationskey exists.hasKey in interface ReactiveRedisOperations<K,V>key - must not be null.public reactor.core.publisher.Mono<DataType> type(K key)
ReactiveRedisOperationskey.type in interface ReactiveRedisOperations<K,V>key - must not be null.public reactor.core.publisher.Flux<K> keys(K pattern)
ReactiveRedisOperationspattern. ReactiveRedisOperations.scan() to iterate over the keyspace as
ReactiveRedisOperations.keys(Object) is a non-interruptible and expensive Redis operation.keys in interface ReactiveRedisOperations<K,V>pattern - must not be null.Flux emitting matching keys one by one.public reactor.core.publisher.Flux<K> scan(ScanOptions options)
ReactiveRedisOperationsFlux to iterate over keys. The resulting Flux acts as a cursor and issues SCAN
commands itself as long as the subscriber signals demand.scan in interface ReactiveRedisOperations<K,V>options - must not be null. Use ScanOptions.NONE instead.Flux emitting the keys one by one or an empty flux if none
exist.public reactor.core.publisher.Mono<K> randomKey()
ReactiveRedisOperationsrandomKey in interface ReactiveRedisOperations<K,V>public reactor.core.publisher.Mono<Boolean> rename(K oldKey, K newKey)
ReactiveRedisOperationsoldKey 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)
ReactiveRedisOperationsoleName 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)
ReactiveRedisOperationskey.delete in interface ReactiveRedisOperations<K,V>keys - must not be null.public reactor.core.publisher.Mono<Long> delete(org.reactivestreams.Publisher<K> keys)
ReactiveRedisOperationskeys. This command buffers keys received from Publisher into chunks of 128 keys to
delete to reduce the number of issued DEL commands.delete in interface ReactiveRedisOperations<K,V>keys - must not be null.@SafeVarargs public final reactor.core.publisher.Mono<Long> unlink(K... keys)
ReactiveRedisOperationskey from the keyspace. Unlike with ReactiveRedisOperations.delete(Object[]) the actual memory reclaiming here
happens asynchronously.unlink in interface ReactiveRedisOperations<K,V>keys - must not be null.public reactor.core.publisher.Mono<Long> unlink(org.reactivestreams.Publisher<K> keys)
ReactiveRedisOperationskeys from the keyspace. Unlike with ReactiveRedisOperations.delete(Publisher) the actual memory reclaiming here
happens asynchronously. This command buffers keys received from Publisher into chunks of 128 keys to delete
to reduce the number of issued UNLINK commands.unlink in interface ReactiveRedisOperations<K,V>keys - must not be null.public reactor.core.publisher.Mono<Boolean> expire(K key, Duration timeout)
ReactiveRedisOperationskey.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)
ReactiveRedisOperationskey 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)
ReactiveRedisOperationskey.persist in interface ReactiveRedisOperations<K,V>key - must not be null.public reactor.core.publisher.Mono<Duration> getExpire(K key)
ReactiveRedisOperationskey.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)
ReactiveRedisOperationskey 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)
ReactiveRedisOperationsRedisScriptexecute 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)
ReactiveRedisOperationsRedisScript, using the provided RedisSerializers 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()
ReactiveRedisOperationsopsForGeo in interface ReactiveRedisOperations<K,V>public <K1,V1> ReactiveGeoOperations<K1,V1> opsForGeo(RedisSerializationContext<K1,V1> serializationContext)
ReactiveRedisOperationsopsForGeo 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()
ReactiveRedisOperationsopsForHash 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)
ReactiveRedisOperationsRedisSerializationContext.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()
ReactiveRedisOperationsopsForHyperLogLog in interface ReactiveRedisOperations<K,V>public <K1,V1> ReactiveHyperLogLogOperations<K1,V1> opsForHyperLogLog(RedisSerializationContext<K1,V1> serializationContext)
ReactiveRedisOperationsRedisSerializationContext.opsForHyperLogLog in interface ReactiveRedisOperations<K,V>serializationContext - serializers to be used with the returned operations, must not be null.public ReactiveListOperations<K,V> opsForList()
ReactiveRedisOperationsopsForList in interface ReactiveRedisOperations<K,V>public <K1,V1> ReactiveListOperations<K1,V1> opsForList(RedisSerializationContext<K1,V1> serializationContext)
ReactiveRedisOperationsRedisSerializationContext.opsForList in interface ReactiveRedisOperations<K,V>serializationContext - serializers to be used with the returned operations, must not be null.public ReactiveSetOperations<K,V> opsForSet()
ReactiveRedisOperationsopsForSet in interface ReactiveRedisOperations<K,V>public <K1,V1> ReactiveSetOperations<K1,V1> opsForSet(RedisSerializationContext<K1,V1> serializationContext)
ReactiveRedisOperationsRedisSerializationContext.opsForSet in interface ReactiveRedisOperations<K,V>serializationContext - serializers to be used with the returned operations, must not be null.public <HK,HV> ReactiveStreamOperations<K,HK,HV> opsForStream()
ReactiveRedisOperationsopsForStream in interface ReactiveRedisOperations<K,V>public <HK,HV> ReactiveStreamOperations<K,HK,HV> opsForStream(HashMapper<? super K,? super HK,? super HV> hashMapper)
ReactiveRedisOperationsopsForStream in interface ReactiveRedisOperations<K,V>hashMapper - the HashMapper to use when mapping complex objects.public <HK,HV> ReactiveStreamOperations<K,HK,HV> opsForStream(RedisSerializationContext<K,?> serializationContext)
ReactiveRedisOperationsRedisSerializationContext.opsForStream in interface ReactiveRedisOperations<K,V>serializationContext - serializers to be used with the returned operations, must not be null.protected <HK,HV> ReactiveStreamOperations<K,HK,HV> opsForStream(RedisSerializationContext<K,?> serializationContext, @Nullable HashMapper<? super K,? super HK,? super HV> hashMapper)
public ReactiveValueOperations<K,V> opsForValue()
ReactiveRedisOperationsopsForValue in interface ReactiveRedisOperations<K,V>public <K1,V1> ReactiveValueOperations<K1,V1> opsForValue(RedisSerializationContext<K1,V1> serializationContext)
ReactiveRedisOperationsRedisSerializationContext.opsForValue in interface ReactiveRedisOperations<K,V>serializationContext - serializers to be used with the returned operations, must not be null.public ReactiveZSetOperations<K,V> opsForZSet()
ReactiveRedisOperationsopsForZSet in interface ReactiveRedisOperations<K,V>public <K1,V1> ReactiveZSetOperations<K1,V1> opsForZSet(RedisSerializationContext<K1,V1> serializationContext)
ReactiveRedisOperationsRedisSerializationContext.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–2021 Pivotal Software, Inc.. All rights reserved.