📅  最后修改于: 2020-11-26 07:06:03             🧑  作者: Mango
Redis脚本用于使用Lua解释器评估脚本。从版本2.6.0开始,它内置在Redis中。用于脚本编写的命令是EVAL命令。
以下是EVAL命令的基本语法。
redis 127.0.0.1:6379> EVAL script numkeys key [key ...] arg [arg ...]
以下示例说明了Redis脚本的工作方式。
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脚本相关的基本命令。
Sr.No | Command & Description |
---|---|
1 | EVAL script numkeys key [key …] arg [arg …]
Executes a Lua script. |
2 | EVALSHA sha1 numkeys key [key …] arg [arg …]
Executes a Lua script. |
3 | SCRIPT EXISTS script [script …]
Checks the existence of scripts in the script cache. |
4 | SCRIPT FLUSH
Removes all the scripts from the script cache. |
5 | SCRIPT KILL
Kills the script currently in execution. |
6 | SCRIPT LOAD script
Loads the specified Lua script into the script cache. |