Closed mmaatuq closed 9 months ago
What's your thinking behind that?
Due to Redis semantics, an empty array (RESP2) or an empty map (RESP3) convey to the caller that the key does not exist, as Redis does not store zero length keys.
how would the new type be useful?
thanks for your reply @michael-grunder I know it's not an issue, it's about convenience, so instead of checking the reply->type == REDIS_REPLY_ARRAY and then check if reply->elements == 0 to decide if the key exists, we could decide that the key doesn't exist if we added this new return type REDIS_REPY_EMPTY_ARRAY.
I can see where you're coming from but unfortunately we can't actually change this as it would be a massive breaking change (also Redis would need to be changed as well).
What I would suggest is doing this check in your app in a convenience function.
In case of hgetall where key doesn't exist, there is an empty array, isn't it more convenient to add a new return type for this instead of array type with elements = 0. It could be equivalent to NIL in case of get command.