Created
May 31, 2015 13:55
-
-
Save phith0n/38c4e5f2f88a690b500c to your computer and use it in GitHub Desktop.
将记录的谷歌搜索词存入redis中
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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