Redis Evalsha Command
The Redis Evalsha command executes a script cached on the server by its sha1 checksum.
Caching a script on the server can be done using the SCRIPT LOAD command.
This command is identical to the EVAL command in other aspects, such as how parameters are passed.
Syntax
The basic syntax for the redis Evalsha command is as follows:
redis 127.0.0.1:6379> EVALSHA sha1 numkeys key [key ...] arg [arg ...]
Parameter explanations:
sha1: The sha1 checksum generated by SCRIPT LOAD.
numkeys: Specifies the number of key name arguments.
key [key ...]: Starting from the third parameter of EVAL, these represent the Redis keys used in the script. These key name arguments can be accessed in Lua via the global KEYS array, with a 1-based index (KEYS[1], KEYS[2], and so on).
arg [arg ...]: Additional arguments, accessible in Lua via the global ARGV array, similar to the KEYS variable (ARGV[1], ARGV[2], and so forth).
Available Versions
= 2.6.0
Example
redis 127.0.0.1:6379> SCRIPT LOAD "return 'hello moto'"
"232fd51614574cf0867b83d384a5e898cfd24e5a"
redis 127.0.0.1:6379> EVALSHA "232fd51614574cf0867b83d384a5e898cfd24e5a" 0
"hello moto"