Initial RESP3 support [d5c54f0b].
This commit is contained in:
parent
f5f855c912
commit
a7a1886b7e
17
read.c
17
read.c
@ -362,7 +362,8 @@ static int processBulkItem(redisReader *r) {
|
|||||||
return REDIS_ERR;
|
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]);
|
redisReadTask *cur = &(r->rstack[r->ridx]);
|
||||||
void *obj;
|
void *obj;
|
||||||
char *p;
|
char *p;
|
||||||
@ -404,10 +405,12 @@ static int processMultiBulkItem(redisReader *r) {
|
|||||||
|
|
||||||
moveToNextTask(r);
|
moveToNextTask(r);
|
||||||
} else {
|
} else {
|
||||||
|
if (cur->type == REDIS_REPLY_MAP) elements *= 2;
|
||||||
|
|
||||||
if (r->fn && r->fn->createArray)
|
if (r->fn && r->fn->createArray)
|
||||||
obj = r->fn->createArray(cur,elements);
|
obj = r->fn->createArray(cur,elements);
|
||||||
else
|
else
|
||||||
obj = (void*)REDIS_REPLY_ARRAY;
|
obj = (void*)(long)cur->type;
|
||||||
|
|
||||||
if (obj == NULL) {
|
if (obj == NULL) {
|
||||||
__redisReaderSetErrorOOM(r);
|
__redisReaderSetErrorOOM(r);
|
||||||
@ -461,6 +464,12 @@ static int processItem(redisReader *r) {
|
|||||||
case '*':
|
case '*':
|
||||||
cur->type = REDIS_REPLY_ARRAY;
|
cur->type = REDIS_REPLY_ARRAY;
|
||||||
break;
|
break;
|
||||||
|
case '%':
|
||||||
|
cur->type = REDIS_REPLY_MAP;
|
||||||
|
break;
|
||||||
|
case '~':
|
||||||
|
cur->type = REDIS_REPLY_SET;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
__redisReaderSetErrorProtocolByte(r,*p);
|
__redisReaderSetErrorProtocolByte(r,*p);
|
||||||
return REDIS_ERR;
|
return REDIS_ERR;
|
||||||
@ -480,7 +489,9 @@ static int processItem(redisReader *r) {
|
|||||||
case REDIS_REPLY_STRING:
|
case REDIS_REPLY_STRING:
|
||||||
return processBulkItem(r);
|
return processBulkItem(r);
|
||||||
case REDIS_REPLY_ARRAY:
|
case REDIS_REPLY_ARRAY:
|
||||||
return processMultiBulkItem(r);
|
case REDIS_REPLY_MAP:
|
||||||
|
case REDIS_REPLY_SET:
|
||||||
|
return processAggregateItem(r);
|
||||||
default:
|
default:
|
||||||
assert(NULL);
|
assert(NULL);
|
||||||
return REDIS_ERR; /* Avoid warning. */
|
return REDIS_ERR; /* Avoid warning. */
|
||||||
|
8
read.h
8
read.h
@ -54,6 +54,14 @@
|
|||||||
#define REDIS_REPLY_NIL 4
|
#define REDIS_REPLY_NIL 4
|
||||||
#define REDIS_REPLY_STATUS 5
|
#define REDIS_REPLY_STATUS 5
|
||||||
#define REDIS_REPLY_ERROR 6
|
#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. */
|
#define REDIS_READER_MAX_BUF (1024*16) /* Default max unused reader buffer. */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user