Skip to content

Commit

Permalink
Merge pull request #263 from areina/add-support-for-sort-command
Browse files Browse the repository at this point in the history
Add support for SORT command in Redis.
  • Loading branch information
idning committed Oct 18, 2014
2 parents b72c722 + abdf204 commit c19c9f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion notes/redis.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
+-------------------+------------+---------------------------------------------------------------------------------------------------------------------+
| RESTORE | Yes | RESTORE key ttl serialized-value |
+-------------------+------------+---------------------------------------------------------------------------------------------------------------------+
| SORT | No | SORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination] |
| SORT | Yes* | SORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination] |
+-------------------+------------+---------------------------------------------------------------------------------------------------------------------+
| TTL | Yes | TTL key |
+-------------------+------------+---------------------------------------------------------------------------------------------------------------------+
Expand All @@ -48,6 +48,8 @@
| SCAN | No | SCAN cursor [MATCH pattern] [COUNT count] |
+-------------------+------------+---------------------------------------------------------------------------------------------------------------------+

* SORT support requires that the supplied keys hash to the same server. You can ensure this by using the same [hashtag](notes/recommendation.md#hash-tags) for all keys in the command.

### Strings Command

+-------------------+------------+---------------------------------------------------------------------------------------------------------------------+
Expand Down
1 change: 1 addition & 0 deletions src/nc_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ typedef enum msg_parse_result {
ACTION( REQ_REDIS_PEXPIREAT ) \
ACTION( REQ_REDIS_PERSIST ) \
ACTION( REQ_REDIS_PTTL ) \
ACTION( REQ_REDIS_SORT ) \
ACTION( REQ_REDIS_TTL ) \
ACTION( REQ_REDIS_TYPE ) \
ACTION( REQ_REDIS_APPEND ) /* redis requests - string */ \
Expand Down
6 changes: 6 additions & 0 deletions src/proto/nc_redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ redis_arg0(struct msg *r)
case MSG_REQ_REDIS_EXISTS:
case MSG_REQ_REDIS_PERSIST:
case MSG_REQ_REDIS_PTTL:
case MSG_REQ_REDIS_SORT:
case MSG_REQ_REDIS_TTL:
case MSG_REQ_REDIS_TYPE:
case MSG_REQ_REDIS_DUMP:
Expand Down Expand Up @@ -588,6 +589,11 @@ redis_parse_req(struct msg *r)
break;
}

if (str4icmp(m, 's', 'o', 'r', 't')) {
r->type = MSG_REQ_REDIS_SORT;
break;
}

break;

case 5:
Expand Down

0 comments on commit c19c9f2

Please sign in to comment.