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 & Remark |
---|---|
1 |
EVAL script numkeys key [key ...] arg [arg ...] 执行一个Lua脚本。 |
2 |
EVALSHA sha1 numkeys key [key ...] arg [arg ...] 执行一个Lua脚本。 |
3 |
SCRIPT EXISTS script [script ...] 检查脚本高速缓存中是否存在脚本。 链接:https://www.learnfk.comhttps://www.learnfk.com/redis/redis-scripting.html 来源:LearnFk无涯教程网 |
4 |
SCRIPT FLUSH 从脚本缓存中删除所有脚本。 |
5 |
SCRIPT KILL 终止当前正在执行的脚本。 |
6 |
SCRIPT LOAD script 将指定的Lua脚本加载到脚本缓存中。 |
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)
Tony Bai · Go语言第一课 -〔Tony Bai〕