Redis Evalsha Command
The Redis Evalsha command executes a script cached on the server based on the given sha1 checksum.
The operation of caching a script to the server can be performed using the SCRIPT LOAD command.
Everything else about this command, such as how parameters are passed, is the same as the EVAL command.
Syntax
The basic syntax of the Redis Evalsha command is as follows:
redis 127.0.0.1:6379> EVALSHA sha1 numkeys key [key ...] arg [arg ...]
Parameter description:
- sha1 sha1: The sha1 checksum generated by SCRIPT LOAD.
- numkeysnumkeys: Used to specify the number of key name parameters.
- key [key ...]key [key ...]: Starting from the third parameter of EVAL, these represent the Redis keys used in the script. These key name parameters can be accessed in Lua via the global variable KEYS array, using 1-based indexing (KEYS
- arg [arg ...]arg [arg ...]: Additional parameters, accessed in Lua via the global variable ARGV array, in a manner similar to the KEYS variable (ARGV
Available Versions
>= 2.6.0
Examples
redis 127.0.0.1:6379> SCRIPT LOAD "return 'hello moto'" "232fd51614574cf0867b83d384a5e898cfd24e5a" redis 127.0.0.1:6379> EVALSHA "232fd51614574cf0867b83d384a5e898cfd24e5a" 0 "hello moto"
Other Extensions