Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redis script command support #677

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lukemakeit
Copy link

Problem

redis script command not support.

Solution

Send the script command to all Redis servers for execution, and get one of the results and return it to the user client.

Result

> script load "return redis.call('hset',KEYS[1],KEYS[1],KEYS[1])"
"dbbae75a09f1390aaf069fb60e951ec23cab7a15"
> script exists dbbae75a09f1390aaf069fb60e951ec23cab7a15
1) (integer) 1

{
struct server *server;
uint32_t idx;

idx = server_pool_idx(pool, key, keylen);
if (r->type == MSG_REQ_REDIS_SCRIPT) {
idx = r->redis_script_idx;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a member named server_index in struct msg. If the value is >=0, use msg->server_index as target server index. In this way, we don't need redis_script_idx and scan_server_idx at all.

@@ -2945,10 +2982,97 @@ redis_fragment_argx(struct msg *r, uint32_t nserver, struct msg_tqh *frag_msgq,
return NC_OK;
}

static rstatus_t redis_fragment_script(struct msg *r, struct msg_tqh *frag_msgq) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we can implement a function redis_fragment_broadcast which can broadcast a request to all servers, we can implement broadcast commands like DBSIZE, FLUSHALL easily. What I mean is this function is not general enough, which can only handle SCRIPT command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants