Skip to content

Instantly share code, notes, and snippets.

@wendal
Created August 8, 2013 14:55
Show Gist options
  • Save wendal/6185313 to your computer and use it in GitHub Desktop.
Save wendal/6185313 to your computer and use it in GitHub Desktop.
通用的redis订阅接口, nginx+lua+redis
location =/subscribe {
send_timeout 365h;
content_by_lua "
local redis = require \"resty.redis\"
local red = redis:new()
red:connect(\"127.0.0.1\", 6379)
red:subscribe(ngx.var.arg_key)
local res, err = red:read_reply()
if res then
ngx.say(res)
else
ngx.status = 500
end
red:close()
";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment