tool ={
}-- 获得 redis 连接function tool.getRedis()local redis =require("resty.redis")local red = redis:new()
red:set_timeout(1000)local ip ="172.20.0.2"local port =6379local ok, err = red:connect(ip, port)ifnot ok then
ngx.say("failed to connect: ", err)returnend
red:auth("root")
ngx.say("connected to redis")return red
end-- 获得 mysql 连接