location /c {
default_type text/plain;
content_by_lua_block {
local index = ngx.shared.index
local count
if(index:get("count") == nil) then
count = 0
else
count = index:get("count")
end
index:set("count",count + 1)
local redis = require 'resty.redis'
local red = redis.new()
red:set_timeout(1000)
local ok, err = red:connect('127.0.0.1', 6379)
ok,err = red:set(count,math.random(100000))
ngx.say('ok...' .. ok)
local ok, err = red:set_keepalive(10000, 100)
if not ok then
ngx.say("failed to set keepalive: ", err)
return
end
}
}
openresty 链接redis配置
最新推荐文章于 2023-06-07 23:01:03 发布