Redis Eval Command
Redis Eval command executes the script 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: The parameter is a Lua 5.1 script program. The script does not need to (and should not) be defined as a Lua function.
- numkeys: Used to specify the number of key-name parameters.
- key [key ...]: Starting from the third parameter of EVAL, they represent the Redis keys used in the script. These key-name parameters can be accessed in Lua via the global variable KEYS array, using a 1-based index (KEYS
- 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
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"
Other Extensions