| 122 | } |
| 123 | |
| 124 | static bool EncodeReply(const RedisReply& reply, butil::IOBuf* out) { |
| 125 | butil::IOBufAppender appender; |
| 126 | // RedisReply::SerializeTo does not support REDIS_REPLY_NIL directly. |
| 127 | // Encode nil as a null bulk string so response parsing can consume it. |
| 128 | if (reply.type() == REDIS_REPLY_NIL) { |
| 129 | appender.append("$-1\r\n", 5); |
| 130 | appender.move_to(*out); |
| 131 | return true; |
| 132 | } |
| 133 | if (!const_cast<RedisReply&>(reply).SerializeTo(&appender)) { |
| 134 | return false; |
| 135 | } |
| 136 | appender.move_to(*out); |
| 137 | return true; |
| 138 | } |
| 139 | |
| 140 | } // namespace |
| 141 |
no test coverage detected