June 04, 2011 02:15PM
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.
Subject Author Posted

lua parser and redis2 questions

gregr401 June 01, 2011 07:27PM

Re: lua parser and redis2 questions

logar.damir June 04, 2011 08:49AM

Re: lua parser and redis2 questions

Marcos Ortiz June 04, 2011 11:12AM

Re: lua parser and redis2 questions

Marcos Ortiz June 04, 2011 11:16AM

Re: lua parser and redis2 questions

agentzh June 04, 2011 11:22AM

Re: lua parser and redis2 questions

gregr401 June 04, 2011 02:15PM

Re: lua parser and redis2 questions

agentzh June 06, 2011 04:06AM

Re: lua parser and redis2 questions

logar.damir June 04, 2011 04:26PM

Re: lua parser and redis2 questions

gregr401 June 05, 2011 06:40PM

Re: lua parser and redis2 questions

agentzh June 06, 2011 04:12AM

Re: lua parser and redis2 questions

logar.damir June 06, 2011 07:16AM

Re: lua parser and redis2 questions

agentzh June 06, 2011 10:56AM

Re: lua parser and redis2 questions

gregr401 June 06, 2011 12:50PM

Re: lua parser and redis2 questions

agentzh June 06, 2011 09:16PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 266
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready