小白教程
所有教程
关于
Search
172.70.179.111
172.70.179.111
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Redis 脚本”的源代码
本页内容
上一节:
Redis_事务
下一节:
Redis_连接
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:Redis 脚本}}[[Category:Redis 教程|16]] = Redis 脚本 = Redis 脚本使用 Lua 解释器来执行脚本。 Redis 2.6 版本通过内嵌支持 Lua 环境。执行脚本的常用命令为 '''EVAL'''。 === 语法 === Eval 命令的基本语法如下: <sample title="" desc="" lang="redis" hererun="1"> redis 127.0.0.1:6379> EVAL script numkeys key [key ...] arg [arg ...] </sample> == 以下实例演示了 redis 脚本工作过程: <sample title="" desc="" lang="redis" hererun="1"> 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" </sample> == Redis 脚本命令 == 下表列出了 redis 脚本常用命令: {| class="table table-striped table-hover" ! 序号 ! 命令及描述 |- | 1 | [[scripting eval|EVAL script numkeys key [key ...] arg [arg ...]]] 执行 Lua 脚本。 |- | 2 | [[scripting evalsha|EVALSHA sha1 numkeys key [key ...] arg [arg ...]]] 执行 Lua 脚本。 |- | 3 | [[scripting script exists|SCRIPT EXISTS script [script ...]]] 查看指定的脚本是否已经被保存在缓存当中。 |- | 4 | [[scripting script flush|SCRIPT FLUSH]] 从脚本缓存中移除所有脚本。 |- | 5 | [[scripting script kill|SCRIPT KILL]] 杀死当前正在运行的 Lua 脚本。 |- | 6 | [[scripting script load|SCRIPT LOAD script]] 将脚本 script 添加到脚本缓存中,但并不立即执行这个脚本。 |}
返回至“
Redis 脚本
”。
上一节:
Redis_事务
下一节:
Redis_连接