org.springframework.data.redis.core.script
Class DefaultScriptExecutor<K>
java.lang.Object
org.springframework.data.redis.core.script.DefaultScriptExecutor<K>
- Type Parameters:
K
- The type of keys that may be passed during script execution
- All Implemented Interfaces:
- ScriptExecutor<K>
public class DefaultScriptExecutor<K>
- extends Object
- implements ScriptExecutor<K>
Default implementation of ScriptExecutor
. Optimizes performance by attempting to execute script first using
evalsha, then falling back to eval if Redis has not yet cached the script. Evalsha is not attempted if the script is
executed in a pipeline or transaction.
Method Summary |
protected
|
deserializeResult(RedisSerializer<T> resultSerializer,
Object result)
|
protected
|
eval(RedisConnection connection,
RedisScript<T> script,
ReturnType returnType,
int numKeys,
byte[][] keysAndArgs,
RedisSerializer<T> resultSerializer)
|
|
execute(RedisScript<T> script,
List<K> keys,
Object... args)
Executes the given RedisScript |
|
execute(RedisScript<T> script,
RedisSerializer<?> argsSerializer,
RedisSerializer<T> resultSerializer,
List<K> keys,
Object... args)
Executes the given RedisScript , using the provided RedisSerializer s to serialize the script
arguments and result. |
protected byte[][] |
keysAndArgs(RedisSerializer argsSerializer,
List<K> keys,
Object[] args)
|
protected RedisSerializer |
keySerializer()
|
protected byte[] |
scriptBytes(RedisScript<?> script)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DefaultScriptExecutor
public DefaultScriptExecutor(RedisTemplate<K,?> template)
- Parameters:
template
- The RedisTemplate
to use
execute
public <T> T execute(RedisScript<T> script,
List<K> keys,
Object... args)
- Description copied from interface:
ScriptExecutor
- Executes the given
RedisScript
- Specified by:
execute
in interface ScriptExecutor<K>
- Parameters:
script
- The script to executekeys
- Any keys that need to be passed to the scriptargs
- Any args that need to be passed to the script
- Returns:
- The return value of the script or null if
RedisScript.getResultType()
is null, likely indicating a
throw-away status reply (i.e. "OK")
execute
public <T> T execute(RedisScript<T> script,
RedisSerializer<?> argsSerializer,
RedisSerializer<T> resultSerializer,
List<K> keys,
Object... args)
- Description copied from interface:
ScriptExecutor
- Executes the given
RedisScript
, using the provided RedisSerializer
s to serialize the script
arguments and result.
- Specified by:
execute
in interface ScriptExecutor<K>
- Parameters:
script
- The script to executeargsSerializer
- The RedisSerializer
to use for serializing argsresultSerializer
- The RedisSerializer
to use for serializing the script return valuekeys
- Any keys that need to be passed to the scriptargs
- Any args that need to be passed to the script
- Returns:
- The return value of the script or null if
RedisScript.getResultType()
is null, likely indicating a
throw-away status reply (i.e. "OK")
eval
protected <T> T eval(RedisConnection connection,
RedisScript<T> script,
ReturnType returnType,
int numKeys,
byte[][] keysAndArgs,
RedisSerializer<T> resultSerializer)
keysAndArgs
protected byte[][] keysAndArgs(RedisSerializer argsSerializer,
List<K> keys,
Object[] args)
scriptBytes
protected byte[] scriptBytes(RedisScript<?> script)
deserializeResult
protected <T> T deserializeResult(RedisSerializer<T> resultSerializer,
Object result)
keySerializer
protected RedisSerializer keySerializer()