Conversation
| r->max_server_idx=(pool->server).nelem; | ||
| }else{ | ||
| idx = server_pool_idx(pool, key, keylen); | ||
| } |
There was a problem hiding this comment.
Change the cursor of request in req_filter and save the server_index on msg in the mean time.
src/proto/nc_redis.c
Outdated
| } | ||
| } | ||
|
|
||
| void redis_post_coalesce_scan(struct msg *request) { |
src/proto/nc_redis.c
Outdated
| return redis_fragment_argx(r, nserver, frag_msgq, 2); | ||
|
|
||
| case MSG_REQ_REDIS_SCAN: | ||
| return redis_fragment_scan(r,frag_msgq); |
There was a problem hiding this comment.
The scan command doesn't need fragment, the thing you want do is change the cursor, you can do this in req_filter.
When response received you need change the cursor again, you can do this in rsp_filter.
src/nc_server.h
Outdated
|
|
||
| uint32_t server_pool_idx(const struct server_pool *pool, const uint8_t *key, uint32_t keylen); | ||
| struct conn *server_pool_conn(struct context *ctx, struct server_pool *pool, const uint8_t *key, uint32_t keylen); | ||
| struct conn *server_pool_conn(struct context *ctx, struct server_pool *pool, const uint8_t *key, uint32_t keylen, struct msg *msg); |
There was a problem hiding this comment.
I think put msg in front of key and keylen is better.
src/nc_server.c
Outdated
| nc_memcpy(key,arr,keylen); | ||
| } | ||
| r->scan_server_idx=idx; | ||
| r->max_server_idx=(pool->server).nelem; |
There was a problem hiding this comment.
I think max_server_idx is unnecessary, since you can always known the number of server by array_n(&pool->server) .
|
Hi @wy-ei , I have re-committed according to your suggestion, thanks. |
src/nc_request.c
Outdated
| } | ||
|
|
||
| if (msg->type == MSG_REQ_REDIS_SCAN) { | ||
| ASSERT(array_n(msg->keys) > 0); |
There was a problem hiding this comment.
move this into a function and call the function here like what you did in rsp_filter.
| unsigned redis:1; /* redis? */ | ||
|
|
||
| uint32_t server_index; /* used for store the redis server index in server pool */ | ||
| }; |
There was a problem hiding this comment.
this comment is not clear enough. how about this one:
the server index which the requstion should be forwarded.
There was a problem hiding this comment.
this comment is not clear enough. how about this one:
the server index which the requstion should be forwarded.
ok
|
@lukexwang I have see the change you made. it's better. And I think the code can be optimized again. I have leave some more suggestions. |
|
Hi @wy-ei , thank you for your suggestion. I have re-committed. |
|
Hello @wy-ei , 空了辛苦看下哈 ^_^ |
|
马晓栋已经收到您的来件,谢谢!
|
redis script command support
…add-scan-support
Problem
redis scan command not support.
Solution
Note:
server_idxis saved by the lowest 12 bits of cursor, so the number of servers of the twemproxy must be less than 4096.Result