Created
April 7, 2012 14:19
-
-
Save bigplum/2329313 to your computer and use it in GitHub Desktop.
issue for lua-resty-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
74 location /test { | |
75 default_type 'text/plain'; | |
76 lua_code_cache off; | |
77 content_by_lua_file luas/test.lua; | |
78 } |
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
local testm = require('testm') | |
ngx.say("ok test") |
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
module('testdb',package.seeall) | |
local redis = require "resty.redis" | |
local mt = { __index = testdb } | |
local rtdb = nil | |
function get_rtdb(self) | |
if self.rtdb then return self.rtdb end | |
self.rtdb = redis:new() | |
self.rtdb:set_timeout(1000) -- 1 sec | |
ngx.log(ngx.ERR, 1) | |
local ok, err = self.rtdb:connect("127.0.0.1", 6381) | |
ngx.log(ngx.ERR, 2) | |
if not ok then | |
return nil | |
end | |
return self.rtdb | |
end | |
return setmetatable({rtdb}, mt) |
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
module('testm',package.seeall) | |
local testdb = require('testdb') | |
local rtdb = testdb:get_rtdb() | |
r,err = rtdb:hmget(123, 'sid', 'uid') | |
ngx.say("ok testm") |
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
module('testm',package.seeall) | |
local testdb = require('testdb') | |
function foo() | |
local rtdb = testdb:get_rtdb() | |
r,err = rtdb:hmget(123, 'sid', 'uid') | |
ngx.say("ok testm") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment