Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

zrange withscores not parsed well #7

Open
beedub opened this Issue · 3 comments

2 participants

@beedub

Parsed reply bodies from zrange with "withscore" option do not have any delimiter between the member and score, thus making the reply almost impossible to interpret.

Some test code below. The /redis location is a raw_response redis interpretor that is used in many of your examples. The output is 1 999888, which is confusing.

local parser = require "redis.parser"
local req = parser.build_query( { "zadd", "test", 888, 999 } )
req = req .. parser.build_query( { "zrange", "test", 0, -1, "withscores" })

local res = ngx.location.capture("/redis?2",
                 { body = req })

local replies = parser.parse_replies(res.body, 2)

-- formatted reply
for i, reply in ipairs(replies) do
   local res, typ = reply[1], reply[2]
   ngx.say(res)
end

(Awesome work on open_resty btw!)

@agentzh
Owner
@agentzh
Owner

BTW, you may also want to take a look at the lua-resty-redis library: https://github.com/agentzh/lua-resty-redis This library is more flexible and more convenient to use than ngx_redis2 + lua-redis-parser. Also lua-resty-redis can be more efficient.

@agentzh
Owner

Any updates on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.