当前位置:   article > 正文

redis之readQueryFromClient_redis 1.0 readqueryfromclient

redis 1.0 readqueryfromclient

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发送的命令;

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小惠珠哦/article/detail/978342
推荐阅读
相关标签
  

闽ICP备14008679号