Redis Eval Command
The Redis Eval command executes scripts using the Lua interpreter.
Syntax
The basic syntax of the redis Eval command is as follows:
redis 127.0.0.1:6379> EVAL script numkeys key [key ...] arg [arg ...]
Parameter description:
script: This parameter is a Lua 5.1 script program. The script does not need (and should not) be defined as a Lua function.
numkeys: Specifies the number of key name parameters.
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, in a 1-based index format (KEYS[1], KEYS[2], and so on).
arg [arg ...]: Additional parameters, which can be accessed in Lua via the global variable ARGV array, similar to the KEYS variable (ARGV[1], ARGV[2], and so on).
Available Versions
= 2.6.0
Example
redis 127.0.0.1:6379> eval "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}" 2 key1 key2 first second
1) "key1"
2) "key2"
3) "first"
4) "second"