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
ConstructorsConstructorDescriptionDefaultReactiveScriptExecutor(ReactiveRedisConnectionFactory connectionFactory, RedisSerializationContext<K, ?> serializationContext) Creates a newDefaultReactiveScriptExecutorgivenReactiveRedisConnectionFactoryandRedisSerializationContext. -
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 providedRedisSerializers to serialize the script arguments and result.protected ByteBuffer[]keysAndArgs(RedisElementWriter argsWriter, List<K> keys, List<?> args) protected RedisSerializationContext.SerializationPair<K>protected ByteBufferscriptBytes(RedisScript<?> script) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.data.redis.core.script.ReactiveScriptExecutor
execute, execute
-
Constructor Details
-
DefaultReactiveScriptExecutor
public DefaultReactiveScriptExecutor(ReactiveRedisConnectionFactory connectionFactory, RedisSerializationContext<K, ?> serializationContext) Creates a newDefaultReactiveScriptExecutorgivenReactiveRedisConnectionFactoryandRedisSerializationContext.- 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:ReactiveScriptExecutorExecutes the givenRedisScript- Specified by:
executein 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:ReactiveScriptExecutorExecutes the givenRedisScript, using the providedRedisSerializers to serialize the script arguments and result.- Specified by:
executein 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- TheRedisElementWriterto use for serializing args. Must not be null.resultReader- TheRedisElementReaderto 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
-