w3resource logo


Redis Tutorial

Redis Scripting: EVAL script numkeys key [key ...] arg [arg ...]

Secondary Nav

Description

Redis EVAL command is used to evaluate scripts using the Lua interpreter. The first argument of EVAL is a Lua 5.1 script and the script does not need to define a Lua function. It is just a Lua program that will run in the context of the Redis server. The second argument of EVAL is the number of arguments that follows the script that represents Redis key names. These arguments can be accessed by Lua using the KEYS global variable in the form of a one-based array (so KEYS[1], KEYS[2], ...).

Syntax

EVAL script numkeys key [key ...] arg [arg ...] 

Available since

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"


Join our Question Answer community to learn and share your programming knowledge.

Help the community:

PHP: Loop

JavaScript: Delete duplicates in an array

Oracle: Round the number