K - The type of keys that may be passed during script executionpublic class DefaultScriptExecutor<K> extends Object implements ScriptExecutor<K>
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.| Constructor and Description |
|---|
DefaultScriptExecutor(RedisTemplate<K,?> template) |
| Modifier and Type | Method and Description |
|---|---|
protected <T> T |
deserializeResult(RedisSerializer<T> resultSerializer,
Object result) |
protected <T> T |
eval(RedisConnection connection,
RedisScript<T> script,
ReturnType returnType,
int numKeys,
byte[][] keysAndArgs,
RedisSerializer<T> resultSerializer) |
<T> T |
execute(RedisScript<T> script,
List<K> keys,
Object... args)
Executes the given
RedisScript |
<T> T |
execute(RedisScript<T> script,
RedisSerializer<?> argsSerializer,
RedisSerializer<T> resultSerializer,
List<K> keys,
Object... args)
Executes the given
RedisScript, using the provided RedisSerializers 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) |
public DefaultScriptExecutor(RedisTemplate<K,?> template)
template - The RedisTemplate to usepublic <T> T execute(RedisScript<T> script, List<K> keys, Object... args)
ScriptExecutorRedisScriptexecute in interface ScriptExecutor<K>script - The script to executekeys - Any keys that need to be passed to the scriptargs - Any args that need to be passed to the scriptRedisScript.getResultType() is null, likely indicating a
throw-away status reply (i.e. "OK")public <T> T execute(RedisScript<T> script, RedisSerializer<?> argsSerializer, RedisSerializer<T> resultSerializer, List<K> keys, Object... args)
ScriptExecutorRedisScript, using the provided RedisSerializers to serialize the script
arguments and result.execute in interface ScriptExecutor<K>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 scriptRedisScript.getResultType() is null, likely indicating a
throw-away status reply (i.e. "OK")protected <T> T eval(RedisConnection connection, RedisScript<T> script, ReturnType returnType, int numKeys, byte[][] keysAndArgs, RedisSerializer<T> resultSerializer)
protected byte[][] keysAndArgs(RedisSerializer argsSerializer, List<K> keys, Object[] args)
protected byte[] scriptBytes(RedisScript<?> script)
protected <T> T deserializeResult(RedisSerializer<T> resultSerializer, Object result)
protected RedisSerializer keySerializer()