lua parser and redis2 questions

logar.damir nginx-forum at nginx.us
Sun Jun 5 00:26:06 MSD 2011


Gregr, I'm using multibulk reply without pipelining.  If it helps,
here's a working sample. 

I haven't used pipelining yet, since support for this a quite new
(2011-04-03 for lua-redis-parser). Maybe try to update agentzh modules
first.


#First save some test values to redis:
location /testluasetnginx
{
    redis2_query hset testkey "testhash1" "value1";
    redis2_query hset testkey "testhash2" "value2";
    redis2_pass redisbackend;
}

#internal location for nonblocking fetch
location /testluagetnginx
{
    redis2_query hgetall testkey;
    redis2_pass redisbackend;
}

#test code
location /testluaparser
{
content_by_lua '
local replies = ngx.location.capture("/testluagetnginx")
local parser = require("redis.parser")
ngx.say("reply status is:",replies.status)
ngx.say("reply body is:",replies.body)
ngx.say("end of showresults")
local res,typ = parser.parse_reply(replies.body)
ngx.say("type=", typ)
ngx.say("res=", res[1])
ngx.say("res=", res[2])
ngx.say("res=", res[3])
ngx.say("res=", res[4])
';
}


#my results when using curl 'http://localhost/testluaparser'
reply status is:200
reply body is:*4
$9
testhash1
$6
value1
$9
testhash2
$6
value2

end of showresults
type=5
res=testhash1
res=value1
res=testhash2
res=value2

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,203154,203946#msg-203946




More information about the nginx mailing list