When using hiredis, use redisAppendCommand to put multiple hincrby commands, the reply->type result of redisGetReply is REDIS_REPLY_INTEGER, and only one of the results is returned.
But when I use hmget, the result of reply->type is REDIS_REPLY_ARRAY.
2
Answers
Thank you very much for answering my question.
And the official reply from HIREDIS is here.
https://github.com/redis/hiredis/issues/1143
Since you call
redisAppendCommand
multiple times, you should callredisGetReply
the same number of times to get all replies. For each reply, it’s of typeREDIS_REPLY_INTEGER
. Because the reply type ofhincrby
is integer type, or array type.The reply type of
hmget
is array reply, and that’s why you getREDIS_REPLY_ARRAY
.Since you tag the question with
c++
, you can try redis-plus-plus, which is a user-friendly C++ client for Redis and you don’t need to parse the reply manually:Disclaimer: I’m the author of redis-plus-plus.