summaryrefslogtreecommitdiff
path: root/src/debug.c
diff options
context:
space:
mode:
authorItamar Haber <itamar@redislabs.com>2018-06-09 21:10:53 +0300
committerGitHub <noreply@github.com>2018-06-09 21:10:53 +0300
commite654b68d1f33313a683eb131477017da667551f0 (patch)
tree238948328a155152b3b6435ca0a0d830bdf0fb21 /src/debug.c
parentfefde6e3e4addf860829d4848386d90889590eac (diff)
parentbe899b824edd312d4e3a1998c56626d66fae3b61 (diff)
downloadredis-e654b68d1f33313a683eb131477017da667551f0.tar.gz
Merge branch 'unstable' into module_command_help
Diffstat (limited to 'src/debug.c')
-rw-r--r--src/debug.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/debug.c b/src/debug.c
index 7a9bddebd..14e753aa9 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -287,12 +287,13 @@ void debugCommand(client *c) {
const char *help[] = {
"ASSERT -- Crash by assertion failed.",
"CHANGE-REPL-ID -- Change the replication IDs of the instance. Dangerous, should be used only for testing the replication subsystem.",
-"CRASH-and-recover <milliseconds> -- Hard crash and restart after <milliseconds> delay.",
+"CRASH-AND-RECOVER <milliseconds> -- Hard crash and restart after <milliseconds> delay.",
"DIGEST -- Output a hex signature representing the current DB content.",
"ERROR <string> -- Return a Redis protocol error with <string> as message. Useful for clients unit tests to simulate Redis errors.",
"HTSTATS <dbid> -- Return hash table statistics of the specified Redis database.",
+"HTSTATS-KEY <key> -- Like htstats but for the hash table stored as key's value.",
"LOADAOF -- Flush the AOF buffers on disk and reload the AOF in memory.",
-"LUA-ALWAYS-REPLICATE-COMMANDS (0|1) -- Setting it to 1 makes Lua replication defaulting to replicating single commands, without the script having to enable effects replication.",
+"LUA-ALWAYS-REPLICATE-COMMANDS <0|1> -- Setting it to 1 makes Lua replication defaulting to replicating single commands, without the script having to enable effects replication.",
"OBJECT <key> -- Show low level info about key and associated value.",
"PANIC -- Crash the server simulating a panic.",
"POPULATE <count> [prefix] [size] -- Create <count> string keys named key:<num>. If a prefix is specified is used instead of the 'key' prefix.",
@@ -300,7 +301,7 @@ void debugCommand(client *c) {
"RESTART -- Graceful restart: save config, db, restart.",
"SDSLEN <key> -- Show low level SDS string info representing key and value.",
"SEGFAULT -- Crash the server with sigsegv.",
-"SET-ACTIVE-EXPIRE (0|1) -- Setting it to 0 disables expiring keys in background when they are not accessed (otherwise the Redis behavior). Setting it to 1 reenables back the default.",
+"SET-ACTIVE-EXPIRE <0|1> -- Setting it to 0 disables expiring keys in background when they are not accessed (otherwise the Redis behavior). Setting it to 1 reenables back the default.",
"SLEEP <seconds> -- Stop the server for <seconds>. Decimals allowed.",
"STRUCTSIZE -- Return the size of different Redis core C structures.",
"ZIPLIST <key> -- Show low level info about the ziplist encoding.",
@@ -547,6 +548,34 @@ NULL
stats = sdscat(stats,buf);
addReplyBulkSds(c,stats);
+ } else if (!strcasecmp(c->argv[1]->ptr,"htstats-key") && c->argc == 3) {
+ robj *o;
+ dict *ht = NULL;
+
+ if ((o = objectCommandLookupOrReply(c,c->argv[2],shared.nokeyerr))
+ == NULL) return;
+
+ /* Get the hash table reference from the object, if possible. */
+ switch (o->encoding) {
+ case OBJ_ENCODING_SKIPLIST:
+ {
+ zset *zs = o->ptr;
+ ht = zs->dict;
+ }
+ break;
+ case OBJ_ENCODING_HT:
+ ht = o->ptr;
+ break;
+ }
+
+ if (ht == NULL) {
+ addReplyError(c,"The value stored at the specified key is not "
+ "represented using an hash table");
+ } else {
+ char buf[4096];
+ dictGetStats(buf,sizeof(buf),ht);
+ addReplyBulkCString(c,buf);
+ }
} else if (!strcasecmp(c->argv[1]->ptr,"change-repl-id") && c->argc == 2) {
serverLog(LL_WARNING,"Changing replication IDs after receiving DEBUG change-repl-id");
changeReplicationId();