From c4ef1d64945fdd707a0136f581c0d946d0334d5c Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 10 Mar 2014 16:35:58 +0100 Subject: [PATCH] DEBUG CMDKEYS added for getKeysFromCommand() testing. Examples: redis 127.0.0.1:6379> debug cmdkeys set foo bar 1) "foo" redis 127.0.0.1:6379> debug cmdkeys mget a b c 1) "a" 2) "b" 3) "c" redis 127.0.0.1:6379> debug cmdkeys zunionstore foo 2 a b 1) "a" 2) "b" 3) "foo" redis 127.0.0.1:6379> debug cmdkeys ping (empty list or set) --- src/debug.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/debug.c b/src/debug.c index 7d9a8bfe..e9863e2f 100644 --- a/src/debug.c +++ b/src/debug.c @@ -363,6 +363,18 @@ void debugCommand(redisClient *c) { { server.active_expire_enabled = atoi(c->argv[2]->ptr); addReply(c,shared.ok); + } else if (!strcasecmp(c->argv[1]->ptr,"cmdkeys") && c->argc >= 3) { + struct redisCommand *cmd = lookupCommand(c->argv[2]->ptr); + int *keys, numkeys, j; + + if (!cmd) { + addReplyError(c,"Invalid command specified"); + return; + } + keys = getKeysFromCommand(cmd,c->argv+2,c->argc-2,&numkeys); + addReplyMultiBulkLen(c,numkeys); + for (j = 0; j < numkeys; j++) addReplyBulk(c,c->argv[keys[j]+2]); + getKeysFreeResult(keys); } else { addReplyErrorFormat(c, "Unknown DEBUG subcommand or wrong number of arguments for '%s'", (char*)c->argv[1]->ptr);