Skip to content

Instantly share code, notes, and snippets.

@phith0n
Created May 31, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phith0n/38c4e5f2f88a690b500c to your computer and use it in GitHub Desktop.
Save phith0n/38c4e5f2f88a690b500c to your computer and use it in GitHub Desktop.
将记录的谷歌搜索词存入redis中
red = redis:new()
red:set_timeout(1000)
local ok, err = red:connect("127.0.0.1", 6379)
if not ok then
ngx.log(ngx.WARN, "failed to connect: ", err)
return
end
ok, err = red:select(2)
if not ok then
ngx.log("failed to select: ", err)
return
end
local args = ngx.req.get_uri_args()
if args["q"] then
local key = getClientIp()
local data, err = red:sadd(key, args["q"])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment