Skip to content

Instantly share code, notes, and snippets.

@bigplum
Created April 7, 2012 14:19
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 bigplum/2329313 to your computer and use it in GitHub Desktop.
Save bigplum/2329313 to your computer and use it in GitHub Desktop.
issue for lua-resty-redis
74 location /test {
75 default_type 'text/plain';
76 lua_code_cache off;
77 content_by_lua_file luas/test.lua;
78 }
local testm = require('testm')
ngx.say("ok test")
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)
module('testm',package.seeall)
local testdb = require('testdb')
local rtdb = testdb:get_rtdb()
r,err = rtdb:hmget(123, 'sid', 'uid')
ngx.say("ok testm")
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