Redis scripts use the Lua interpreter to execute scripts. Reids version 2.6 supports the Lua environment via built-in. The common command to execute scripts is EVAL.
Syntax
The basic syntax of the Eval command is as follows:
redis 127.0.0.1:6379> EVAL script numkeys key [key ...] arg [arg ...]
Example
The following example demonstrates the redis script working process:
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 commands
The following table lists common commands for redis scripts:
| Serial number | Command and description |
|---|---|
| 1 | EVAL script numkeys key [key ...] arg [arg ...] Execute Lua script. |
| 2 | EVALSHA sha1 numkeys key [key ...] arg [arg ...] Execute Lua script. |
| 3 | SCRIPT EXISTS script [script ...] Check whether the specified script has been saved in the cache. |
| 4 | SCRIPT FLUSH Remove all scripts from the script cache. |
| 5 | SCRIPT KILL Kill the currently running Lua script. |
| 6 | SCRIPT LOAD script Add script script to the script cache, but do not execute the script immediately. |












![Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]](https://img.php.cn/upload/course/000/000/035/5d27fb58823dc974.jpg)









