mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-07-02 14:04:22 +00:00
Don't choke on nil replies from Redis.
This commit is contained in:
parent
1aacca9e21
commit
034ebca873
3 changed files with 11 additions and 2 deletions
|
@ -64,6 +64,8 @@ namespace redis {
|
|||
return ErrorString(parReply->str, parReply->len);
|
||||
case REDIS_REPLY_STATUS:
|
||||
return StatusString(parReply->str, parReply->len);
|
||||
case REDIS_REPLY_NIL:
|
||||
return nullptr;
|
||||
default:
|
||||
assert(false); //not reached
|
||||
return Reply();
|
||||
|
|
|
@ -26,6 +26,10 @@ namespace redis {
|
|||
}
|
||||
|
||||
const std::string& get_string (const Reply& parReply) {
|
||||
static const std::string empty_str;
|
||||
if (RedisVariantType_Nil == parReply.which())
|
||||
return empty_str;
|
||||
|
||||
assert(RedisVariantType_String == parReply.which());
|
||||
return boost::get<std::string>(parReply);
|
||||
}
|
||||
|
|
|
@ -53,7 +53,8 @@ namespace redis {
|
|||
std::string,
|
||||
std::vector<Reply>,
|
||||
ErrorString,
|
||||
StatusString
|
||||
StatusString,
|
||||
std::nullptr_t
|
||||
>;
|
||||
} //namespace implem
|
||||
enum RedisVariantTypes {
|
||||
|
@ -61,7 +62,8 @@ namespace redis {
|
|||
RedisVariantType_String,
|
||||
RedisVariantType_Array,
|
||||
RedisVariantType_Error,
|
||||
RedisVariantType_Status
|
||||
RedisVariantType_Status,
|
||||
RedisVariantType_Nil
|
||||
};
|
||||
|
||||
struct Reply : implem::RedisVariantType {
|
||||
|
@ -73,6 +75,7 @@ namespace redis {
|
|||
Reply ( std::vector<Reply>&& parVal ) : base_class(std::move(parVal)) {}
|
||||
Reply ( ErrorString&& parVal ) : base_class(std::move(parVal)) {}
|
||||
Reply ( StatusString&& parVal ) : base_class(std::move(parVal)) {}
|
||||
Reply ( std::nullptr_t parVal ) : base_class(parVal) {}
|
||||
~Reply ( void ) noexcept = default;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue