目前打算用openresty做一个网关限流,于是我引用了openresty,代码如下
location / {
default_type text/html;
access_log logs/access.log main;
content_by_lua_block {
local redis = require("resty.redis")
local instance=redis:new()
local ok,err = instance:connect("host",6379)
if not ok then
ngx.say("连接redis失败",err)
return
end
-- 密码认证
instance:auth("pwd")
-- 设置一个key
local value,error=instance:call('set','hello','123')
ngx.say('result',value,error)
}
}
然后我发现设置值失败了,于是我用instance:set(key,value) 的形式,但是又发现无法设置过期时间,附上报错
resultfalseERR unknown command call
, with args beginning with: set
, hello
, 123
,