Skip to content

Latest commit

 

History

History
26 lines (19 loc) · 1.49 KB

eval.md

File metadata and controls

26 lines (19 loc) · 1.49 KB

Invoke the execution of a server-side Lua script.

The first argument is the script's source code. Scripts are written in Lua and executed by the embedded Lua 5.1 interpreter in Redis.

The second argument is the number of input key name arguments, followed by all the keys accessed by the script. These names of input keys are available to the script as the KEYS global runtime variable Any additional input arguments should not represent names of keys.

Important: To ensure the correct execution of scripts, both in standalone and clustered deployments, all names of keys that a script accesses must be explicitly provided as input key arguments. The script should only access keys whose names are given as input arguments. Scripts should never access keys with programmatically-generated names or based on the contents of data structures stored in the database. If a key with expiry (TTL) exists at the start of eval, it will not get expired during the evaluation of a script. During the evaluation of a Lua script, TTL of a key can go down to zero. After that, it remains zero until the script terminates.

Please refer to the Redis Programmability and Introduction to Eval Scripts for more information about Lua scripts.

@examples

The following example will run a script that returns the first argument that it gets.

> EVAL "return ARGV[1]" 0 hello
"hello"