Yes, seems like it should. But I get the error "not initialized". Weird, because red:connect("127.0.0.1", 6379) does not throw any error. Not sure whats going on.
On Monday, September 8, 2014 4:48:39 PM UTC+5:30, Vladislav Manchev wrote:
Hello!
On Mon, Sep 8, 2014 at 2:04 PM, Samarjit Uppal
<uppal...@gmail.com> wrote:
Hello,
The below code seems to be connecting to redis just fine (no error output). But on trying any redis (get or set etc) operation I keep getting "not initialized" message. Strangely, the same code was working fine earlier, so I suspect there is something else going on here. Thanks for your help.
location / {
default_type "text/plain";
content_by_lua '
local redis = require "resty.redis"
local red = redis:new()
red:set_timeout(1000)
local ok, err = red:connect("127.0.0.1", 6379)
if not ok then
ngx.say("failed to connect: ", err)
return
end
ngx.req.read_body()
local body_data = ngx.req.get_body_data()
ok, err = red.lpush("master", body_data)
This should definitely read red:lpush.
if not ok then
ngx.say("failed to push to list", err);
end
.
Best,
Vladislav