Latest web development tutorials

Redis Eval command

Redis script

Redis Eval command uses the Lua interpreter to execute the script.

grammar

redis Eval basic command syntax is as follows:

redis 127.0.0.1:6379> EVAL script numkeys key [key ...] arg [arg ...] 

Parameter Description:

  • script: Parameter is a piece of Lua 5.1 script.Script does not (and should not) be defined as a Lua function.
  • numkeys: for the number of parameters specified key.
  • key [key ...]: From the third argument EVAL start date, showing in the script used by the those Redis key (key), the key name parameters can be global variables KEYS array in Lua, with 1 in the form of base address access (KEYS [1], KEYS [2], and so on).
  • arg [arg ...]: additional parameters in Lua through the global variable ARGV array access, forms and variable access KEYS similar (ARGV [1], ARGV [ 2], and so on).

Available versions

> = 2.6.0

Examples

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"

Redis script