Skip to content

Commit

Permalink
redis: handling SCRIPT command
Browse files Browse the repository at this point in the history
  • Loading branch information
umegaya committed Oct 21, 2015
1 parent 619b55b commit 8158d2e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/nc_message.h
Expand Up @@ -161,6 +161,7 @@ typedef enum msg_parse_result {
ACTION( REQ_REDIS_ZSCORE ) \
ACTION( REQ_REDIS_ZUNIONSTORE ) \
ACTION( REQ_REDIS_ZSCAN) \
ACTION( REQ_REDIS_SCRIPT ) /* redis requests - script */ \
ACTION( REQ_REDIS_EVAL ) /* redis requests - eval */ \
ACTION( REQ_REDIS_EVALSHA ) \
ACTION( REQ_REDIS_PING ) /* redis requests - ping/quit */ \
Expand Down
26 changes: 26 additions & 0 deletions src/proto/nc_redis.c
Expand Up @@ -249,6 +249,8 @@ redis_argn(struct msg *r)
case MSG_REQ_REDIS_ZREVRANGEBYSCORE:
case MSG_REQ_REDIS_ZUNIONSTORE:
case MSG_REQ_REDIS_ZSCAN:

case MSG_REQ_REDIS_SCRIPT:
return true;

default:
Expand Down Expand Up @@ -316,6 +318,25 @@ redis_argeval(struct msg *r)
return false;
}


/*
* return true if the redis command needs to broadcast to all cluster members.
*
*/
static bool
redis_need_bcast(struct msg *r)
{
switch (r->type) {
case MSG_REQ_REDIS_SCRIPT:
return true;

default:
break;
}

return false;
}

/*
* Return true, if the redis response is an error response i.e. a simple
* string whose first character is '-', otherwise return false.
Expand Down Expand Up @@ -879,6 +900,11 @@ redis_parse_req(struct msg *r)
break;
}

if (str6icmp(m, 's', 'c', 'r', 'i', 'p', 't')) {
r->type = MSG_REQ_REDIS_SCRIPT;
break;
}

break;

case 7:
Expand Down

0 comments on commit 8158d2e

Please sign in to comment.