openresty / lua-resty-redis

Lua redis client driver for the ngx_lua based on the cosocket API
1.9k stars 448 forks source link

about hmget & hmset #58

Open 6api opened 9 years ago

6api commented 9 years ago

local res, err hmget(mykey, "one", "two", "three")

then res.one (not worked)

when mykey not exists,the below code not worked

if (res[2] ~= nil) then
    ngx.say('exists') -- when mykey not exists, this line would output
end

and the type of mykey is userdata, how can i convert it to table?

agentzh commented 9 years ago

@6api My hunch is that you use the hmget and hmset commands in the wrong way or you have wrong expectations about them. lua-resty-redis is just a THIN wrapper around redis's protocol, so ensure you have checked out the official Redis command reference for these commands below:

http://redis.io/commands/hmget

http://redis.io/commands/hmset

BTW, the lua-cjson library is your friend to debug the output, see

https://github.com/openresty/lua-resty-redis#debugging

If you have already tried all the above and still believe there is an issue in lua-resty-redis, please provide a minimal but still complete example that can easily demonstrate the problem on my side. Thank you. Simply telling me "not worked" does not help at all for me to diagnose issues for you :)