English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Redis Eval Command uses the Lua interpreter to execute scripts.
Basic Syntax of Redis Eval Command
redis 127.0.0.1:6379> EVAL script numkeys key [key ...] arg [arg ...]
Parameter Description:
script: The parameter is a Lua 5.1 : The script program. The script does not need (nor should it) 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, it represents the Redis keys (key) used in the script, these key name parameters can be accessed in Lua through the global variable KEYS array, using 1 : Access in the form of base address ( KEYS[1] , KEYS[2] , and so on).
arg [arg ...]: Additional parameters, accessible in Lua through the global variable ARGV array, accessed in a similar manner to KEYS variable ( ARGV[1] , ARGV[2] , such as this).
>= 2.6.0
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"