local redis = require "resty.redis"
local red = redis:new() red:set_timeout() -- sec -- or connect to a unix domain socket file listened
-- by a redis server:
-- local ok, err = red:connect("unix:/path/to/redis.sock") local ok, err = red:connect("127.0.0.1", )
if not ok then
ngx.say("failed to connect: ", err)
return
end ok, err = red:set("dog", "an animal")
if not ok then
ngx.say("failed to set dog: ", err)
return
end ngx.say("set result: ", ok) local res, err = red:get("dog")
if not res then
ngx.say("failed to get dog: ", err)
return
end if res == ngx.null then
ngx.say("dog not found.")
return
end ngx.say("dog: ", res) red:init_pipeline()
red:set("cat", "Marry")
red:set("horse", "Bob")
red:get("cat")
red:get("horse")
local results, err = red:commit_pipeline()
if not results then
ngx.say("failed to commit the pipelined requests: ", err)
return
end for i, res in ipairs(results) do
if type(res) == "table" then
if res[] == false then
ngx.say("failed to run command ", i, ": ", res[])
else
-- process the table value
end
else
-- process the scalar value
end
end -- put it into the connection pool of size ,
-- with seconds max idle time
local ok, err = red:set_keepalive(, )
if not ok then
ngx.say("failed to set keepalive: ", err)
return
end -- or just close the connection right away:
-- local ok, err = red:close()
-- if not ok then
-- ngx.say("failed to close: ", err)
-- return
-- end
';

最新文章

  1. js_多个引号的用法
  2. Java使用Jdbc操作MySql数据库(一)
  3. Unity3D独立游戏开发日记(二):摆放建筑物
  4. cocos2dx lua学习笔记 <一> quick 3.5定义本身C++类是必然lua
  5. 线段树(维护最大值):HDU Billboard
  6. php过滤参数特殊字符防注入
  7. Sql 高效分页
  8. [LeetCode]题解(python):027-Remove Element
  9. php生成html 伪静态??
  10. Javac 编译原理
  11. bat处理快速安装jdk脚本
  12. sql 范式:1NF、2NF、3NF、BCNF(函数依赖)
  13. angular中使用ckplayer播放器
  14. fetch API & upload file
  15. thinkphp 外部js语言包
  16. 如何配置Notepad++的C_C++语言开发环境
  17. CS中窗体的基类(BaseForm)注意点
  18. 第12章—使用NoSQL数据库—使用MongoDB+Jpa操作数据库
  19. VMware下CenOS7系统的安装及lnmp服务器的搭建
  20. golang之math/rand随机数

热门文章

  1. python 随机选择字符串中的一个字符
  2. python开发_sqlite3_绝对完整_博主推荐
  3. web 移动端事件总结
  4. gcd 与 扩gcd 总结
  5. Integer与int的种种比较你知道多少
  6. HTML5安全:CORS(跨域资源共享)简介【转】
  7. 201621123006 《Java程序设计》第9周学习总结
  8. 让黑白的SecureCRT彩色起来
  9. adb命令安装apk
  10. hadoop2.x常用端口及定义方法