Redis Eval Command
--
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
Redis Tutorial
Redis Tutorial
Redis Introduction
Redis Installation
Redis Configuration
Redis Data Types
Redis Commands
Redis Commands
Redis Keys
Redis Strings
Redis Hashes
Redis Lists
Redis Sets
Redis Sorted Sets
Redis HyperLogLog
Redis Pub/Sub
Redis Transactions
Redis Scripting
Redis Connection
Redis Server
Redis GEO
Redis Stream
Advanced Redis Tutorial
Redis Backup and Recovery
Redis Security
Redis Performance Testing
Redis Client Connection
Redis Pipelining
Redis Partitioning
Java Using Redis
PHP Using Redis
Redis Scripting
Redis Evalsha Command
Redis Eval Command
Redis Scripting
The Redis Eval command executes scripts 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. 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, these represent the Redis keys used in the script. These key name parameters can be accessed in Lua through the global variable KEYS array, with a base address of 1 (KEYS, KEYS, etc.).
- arg [arg ...]: Additional arguments, accessible in Lua through the global variable ARGV array, similar to the KEYS variable (ARGV, ARGV, etc.).
Available Version
>= 2.6.0
Example
redis 127.0.0.1:6379> eval "return {KEYS,KEYS,ARGV,ARGV}" 2 key1 key2 first second
1) "key1"
2) "key2"
3) "first"
4) "second"
YouTip