mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-07-16 16:24:12 +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);
|
return ErrorString(parReply->str, parReply->len);
|
||||||
case REDIS_REPLY_STATUS:
|
case REDIS_REPLY_STATUS:
|
||||||
return StatusString(parReply->str, parReply->len);
|
return StatusString(parReply->str, parReply->len);
|
||||||
|
case REDIS_REPLY_NIL:
|
||||||
|
return nullptr;
|
||||||
default:
|
default:
|
||||||
assert(false); //not reached
|
assert(false); //not reached
|
||||||
return Reply();
|
return Reply();
|
||||||
|
|
|
@ -26,6 +26,10 @@ namespace redis {
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& get_string (const Reply& parReply) {
|
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());
|
assert(RedisVariantType_String == parReply.which());
|
||||||
return boost::get<std::string>(parReply);
|
return boost::get<std::string>(parReply);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,8 @@ namespace redis {
|
||||||
std::string,
|
std::string,
|
||||||
std::vector<Reply>,
|
std::vector<Reply>,
|
||||||
ErrorString,
|
ErrorString,
|
||||||
StatusString
|
StatusString,
|
||||||
|
std::nullptr_t
|
||||||
>;
|
>;
|
||||||
} //namespace implem
|
} //namespace implem
|
||||||
enum RedisVariantTypes {
|
enum RedisVariantTypes {
|
||||||
|
@ -61,7 +62,8 @@ namespace redis {
|
||||||
RedisVariantType_String,
|
RedisVariantType_String,
|
||||||
RedisVariantType_Array,
|
RedisVariantType_Array,
|
||||||
RedisVariantType_Error,
|
RedisVariantType_Error,
|
||||||
RedisVariantType_Status
|
RedisVariantType_Status,
|
||||||
|
RedisVariantType_Nil
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Reply : implem::RedisVariantType {
|
struct Reply : implem::RedisVariantType {
|
||||||
|
@ -73,6 +75,7 @@ namespace redis {
|
||||||
Reply ( std::vector<Reply>&& parVal ) : base_class(std::move(parVal)) {}
|
Reply ( std::vector<Reply>&& parVal ) : base_class(std::move(parVal)) {}
|
||||||
Reply ( ErrorString&& parVal ) : base_class(std::move(parVal)) {}
|
Reply ( ErrorString&& parVal ) : base_class(std::move(parVal)) {}
|
||||||
Reply ( StatusString&& 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;
|
~Reply ( void ) noexcept = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue