Class DefaultReactiveScriptExecutor<K>
java.lang.Object
org.springframework.data.redis.core.script.DefaultReactiveScriptExecutor<K>
- Type Parameters:
K
- The type of keys that may be passed during script execution
- All Implemented Interfaces:
ReactiveScriptExecutor<K>
Default implementation of
ReactiveScriptExecutor
. Optimizes performance by attempting to execute script first
using EVALSHA
, then falling back to EVAL
if Redis has not yet cached the script.- Since:
- 2.0
- Author:
- Mark Paluch, Christoph Strobl, John Blum
-
Constructor Summary
ConstructorDescriptionDefaultReactiveScriptExecutor
(ReactiveRedisConnectionFactory connectionFactory, RedisSerializationContext<K, ?> serializationContext) Creates a newDefaultReactiveScriptExecutor
givenReactiveRedisConnectionFactory
andRedisSerializationContext
. -
Method Summary
Modifier and TypeMethodDescriptionprotected <T> reactor.core.publisher.Flux<T>
deserializeResult
(RedisElementReader<T> reader, reactor.core.publisher.Flux<T> result) protected <T> reactor.core.publisher.Flux<T>
eval
(ReactiveRedisConnection connection, RedisScript<T> script, ReturnType returnType, int numKeys, ByteBuffer[] keysAndArgs, RedisElementReader<T> resultReader) <T> reactor.core.publisher.Flux<T>
execute
(RedisScript<T> script, List<K> keys, List<?> args) Executes the givenRedisScript
<T> reactor.core.publisher.Flux<T>
execute
(RedisScript<T> script, List<K> keys, List<?> args, RedisElementWriter<?> argsWriter, RedisElementReader<T> resultReader) Executes the givenRedisScript
, using the providedRedisSerializer
s to serialize the script arguments and result.protected ByteBuffer[]
keysAndArgs
(RedisElementWriter argsWriter, List<K> keys, List<?> args) protected RedisSerializationContext.SerializationPair<K>
protected ByteBuffer
scriptBytes
(RedisScript<?> script) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.redis.core.script.ReactiveScriptExecutor
execute, execute
-
Constructor Details
-
DefaultReactiveScriptExecutor
public DefaultReactiveScriptExecutor(ReactiveRedisConnectionFactory connectionFactory, RedisSerializationContext<K, ?> serializationContext) Creates a newDefaultReactiveScriptExecutor
givenReactiveRedisConnectionFactory
andRedisSerializationContext
.- Parameters:
connectionFactory
- must not be null.serializationContext
- must not be null.
-
-
Method Details
-
execute
public <T> reactor.core.publisher.Flux<T> execute(RedisScript<T> script, List<K> keys, List<?> args) Description copied from interface:ReactiveScriptExecutor
Executes the givenRedisScript
- Specified by:
execute
in interfaceReactiveScriptExecutor<K>
- Parameters:
script
- The script to execute. Must not be null.keys
- Any keys that need to be passed to the script. Must not be null.args
- Any args that need to be passed to the script. Can be empty.- Returns:
- The return value of the script or
Flux.empty()
ifRedisScript.getResultType()
is null, likely indicating a throw-away status reply (i.e. "OK")
-
execute
public <T> reactor.core.publisher.Flux<T> execute(RedisScript<T> script, List<K> keys, List<?> args, RedisElementWriter<?> argsWriter, RedisElementReader<T> resultReader) Description copied from interface:ReactiveScriptExecutor
Executes the givenRedisScript
, using the providedRedisSerializer
s to serialize the script arguments and result.- Specified by:
execute
in interfaceReactiveScriptExecutor<K>
- Parameters:
script
- The script to execute. must not be null.keys
- Any keys that need to be passed to the scriptargs
- Any args that need to be passed to the scriptargsWriter
- TheRedisElementWriter
to use for serializing args. Must not be null.resultReader
- TheRedisElementReader
to use for serializing the script return value. Must not be null.- Returns:
- The return value of the script or
Flux.empty()
ifRedisScript.getResultType()
is null, likely indicating a throw-away status reply (i.e. "OK")
-
eval
protected <T> reactor.core.publisher.Flux<T> eval(ReactiveRedisConnection connection, RedisScript<T> script, ReturnType returnType, int numKeys, ByteBuffer[] keysAndArgs, RedisElementReader<T> resultReader) -
keysAndArgs
-
scriptBytes
-
deserializeResult
protected <T> reactor.core.publisher.Flux<T> deserializeResult(RedisElementReader<T> reader, reactor.core.publisher.Flux<T> result) -
keySerializer
-
getConnectionFactory
-