diff options
author | Yossi Gottlieb <yossigo@gmail.com> | 2019-08-04 11:55:24 +0300 |
---|---|---|
committer | Yossi Gottlieb <yossigo@gmail.com> | 2019-08-04 11:55:24 +0300 |
commit | a7a1886b7eaeac0265af419a3f9c0793e7098d46 (patch) | |
tree | 8fbb2bbf518d26b770d0390bebfcc042c9b047cb | |
parent | f5f855c91239706b173e2412cea301f4a3643e2d (diff) |
Initial RESP3 support [d5c54f0b].
-rw-r--r-- | read.c | 17 | ||||
-rw-r--r-- | read.h | 8 |
2 files changed, 22 insertions, 3 deletions
@@ -362,7 +362,8 @@ static int processBulkItem(redisReader *r) { return REDIS_ERR; } -static int processMultiBulkItem(redisReader *r) { +/* Process the array, map and set types. */ +static int processAggregateItem(redisReader *r) { redisReadTask *cur = &(r->rstack[r->ridx]); void *obj; char *p; @@ -404,10 +405,12 @@ static int processMultiBulkItem(redisReader *r) { moveToNextTask(r); } else { + if (cur->type == REDIS_REPLY_MAP) elements *= 2; + if (r->fn && r->fn->createArray) obj = r->fn->createArray(cur,elements); else - obj = (void*)REDIS_REPLY_ARRAY; + obj = (void*)(long)cur->type; if (obj == NULL) { __redisReaderSetErrorOOM(r); @@ -461,6 +464,12 @@ static int processItem(redisReader *r) { case '*': cur->type = REDIS_REPLY_ARRAY; break; + case '%': + cur->type = REDIS_REPLY_MAP; + break; + case '~': + cur->type = REDIS_REPLY_SET; + break; default: __redisReaderSetErrorProtocolByte(r,*p); return REDIS_ERR; @@ -480,7 +489,9 @@ static int processItem(redisReader *r) { case REDIS_REPLY_STRING: return processBulkItem(r); case REDIS_REPLY_ARRAY: - return processMultiBulkItem(r); + case REDIS_REPLY_MAP: + case REDIS_REPLY_SET: + return processAggregateItem(r); default: assert(NULL); return REDIS_ERR; /* Avoid warning. */ @@ -54,6 +54,14 @@ #define REDIS_REPLY_NIL 4 #define REDIS_REPLY_STATUS 5 #define REDIS_REPLY_ERROR 6 +#define REDIS_REPLY_DOUBLE 7 +#define REDIS_REPLY_BOOL 8 +#define REDIS_REPLY_VERB 9 +#define REDIS_REPLY_MAP 9 +#define REDIS_REPLY_SET 10 +#define REDIS_REPLY_ATTR 11 +#define REDIS_REPLY_PUSH 12 +#define REDIS_REPLY_BIGNUM 13 #define REDIS_READER_MAX_BUF (1024*16) /* Default max unused reader buffer. */ |