void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask)
读数据到redisClient::querybuf;
读到数据超过client_max_querybuf_len时,直接freeClient(c);
processInputBuffer(c);
1、输入以*开头,则reqtype为REDIS_REQ_MULTIBULK,调用processMultibulkBuffer(c);
2、否则,reqtype为REDIS_REQ_INLINE,调用processInlineBuffer(c);
3、调用processCommand(c);
int processInlineBuffer(redisClient *c)
strstr(c->querybuf,"\r\n")找行尾;
argv = sdssplitlen(c->querybuf,querylen," ",1,&argc),按空格分隔每个参数;
更新c->querybuf;
根据argv设置c->argv;
int processMultibulkBuffer(redisClient *c)
解析请求,请求格式如下:
*multibulklen\r\n
$bulklen\r\n
..........\r\n
$bulklen\r\n
..........\r\n
multibulklen指定有多少个bulk,bulklen指定每个bulk的长度;
multibulklen范围[0, 1024*1024];
bulklen范围[0,512*1024*1024];
更新c->querybuf;
根据argv设置c->argv;
int processCommand(redisClient *c)
处理client发送的命令;