mirror of
https://github.com/fluencelabs/redis
synced 2025-06-12 16:51:22 +00:00
CLUSTER GETKEYSINSLOT implemented
This commit is contained in:
@ -1209,6 +1209,27 @@ void clusterCommand(redisClient *c) {
|
||||
sds key = c->argv[2]->ptr;
|
||||
|
||||
addReplyLongLong(c,keyHashSlot(key,sdslen(key)));
|
||||
} else if (!strcasecmp(c->argv[1]->ptr,"getkeysinslot") && c->argc == 4) {
|
||||
long long maxkeys, slot;
|
||||
unsigned int numkeys;
|
||||
int j;
|
||||
robj **keys;
|
||||
|
||||
if (getLongLongFromObjectOrReply(c,c->argv[2],&slot,NULL) != REDIS_OK)
|
||||
return;
|
||||
if (getLongLongFromObjectOrReply(c,c->argv[3],&maxkeys,NULL) != REDIS_OK)
|
||||
return;
|
||||
if (slot < 0 || slot >= REDIS_CLUSTER_SLOTS || maxkeys < 0 ||
|
||||
maxkeys > 1024*1024) {
|
||||
addReplyError(c,"Invalid slot or number of keys");
|
||||
return;
|
||||
}
|
||||
|
||||
keys = zmalloc(sizeof(robj*)*maxkeys);
|
||||
numkeys = GetKeysInSlot(slot, keys, maxkeys);
|
||||
addReplyMultiBulkLen(c,numkeys);
|
||||
for (j = 0; j < numkeys; j++) addReplyBulk(c,keys[j]);
|
||||
zfree(keys);
|
||||
} else {
|
||||
addReplyError(c,"Wrong CLUSTER subcommand or number of arguments");
|
||||
}
|
||||
|
Reference in New Issue
Block a user