lua parser and redis2 questions

gregr401 nginx-forum at nginx.us
Sat Jun 4 22:15:13 MSD 2011


Thanks for the responses!  Everything on the redis end is fine and I am
expecting the raw responses by leveraging your redis parser, it's within
the parser examples I'm not making any progress. I'd like to be able to
parse out and set each value to a variable.

Here's my test locations and log snippet, hopefully I'm just missing
something obvious :)

## redis auth is off at this point, just trying to get a pipeline parse
working ok
location /redis2 {
                set $key $http_host;
 
                redis2_query get $key;
                redis2_query get foo;
                redis2_pass redis-backend;
}

##hitting this directly in a browser returns:
$11
auth is off
$3
bar


location /mytest {
                content_by_lua '
                        local replies = ngx.location.capture("/redis2")
                        local parser = require("redis.parser")
                        -- assuming the replies variable holds n redis
responses
                        -- to be parsed:
                        -- tried this in case n needed set:  local
results = parser.parse_replies(replies, 2), same error
                        local results = parser.parse_replies(replies,
n)
                        for i, result in ipairs(results) do
                                local res = result[1]
                                local typ = result[2]
                                ngx.print(res)
                                ngx.print(typ)
                                -- res and typ have exactly the same
meaning as in
                                -- the parse_reply method documented
above
                        end
                ';
        }
## results in 500 and below error snippet

I see the following in the error log:

 [error] 4921#0: *3 lua handler aborted: runtime error: [string
"content_by_lua"]:6: attempt to call field 'parse_replies' (a nil value)
while sending to client  request: "GET /mytest HTTP/1.1"


On a separate note, I've noticed when using Maxim's wonderful keepalive
upstream module between redis, an established connection that performs a
redis AUTH will actually maintain that 'authed' state for any subsequent
redis calls (even those with no specific AUTH call).   I'd imagine these
will work till the connections eventually timeout, keep this in mind
when testing when using redis && auth.

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




More information about the nginx mailing list