RESP3: addReplyNullArray() added for better RESP2 compat.

This commit is contained in:
antirez 2018-11-30 16:31:02 +01:00
parent 86c30a92f9
commit 1a17cdfadf
2 changed files with 13 additions and 0 deletions

View File

@ -611,6 +611,18 @@ void addReplyNull(client *c) {
}
}
/* A null array is a concept that no longer exists in RESP3. However
* RESP2 had it, so API-wise we have this call, that will emit the correct
* RESP2 protocol, however for RESP3 the reply will always be just the
* Null type "_\r\n". */
void addReplyNullArray(client *c) {
if (c->resp == 2) {
addReplyString(c,"*-1\r\n",5);
} else {
addReplyString(c,"_\r\n",3);
}
}
/* Create the length prefix of a bulk reply, example: $2234 */
void addReplyBulkLen(client *c, robj *obj) {
size_t len;

View File

@ -1438,6 +1438,7 @@ void acceptTcpHandler(aeEventLoop *el, int fd, void *privdata, int mask);
void acceptUnixHandler(aeEventLoop *el, int fd, void *privdata, int mask);
void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask);
void addReplyNull(client *c);
void addReplyNullArray(client *c);
void addReplyString(client *c, const char *s, size_t len);
void addReplyBulk(client *c, robj *obj);
void addReplyBulkCString(client *c, const char *s);