]> git.saurik.com Git - redis.git/commitdiff
number of keys info in INFO command thanks to Diego Rosario Brogna
authorantirez <antirez@gmail.com>
Sun, 14 Jun 2009 21:34:25 +0000 (23:34 +0200)
committerantirez <antirez@gmail.com>
Sun, 14 Jun 2009 21:34:25 +0000 (23:34 +0200)
TODO
redis.c

diff --git a/TODO b/TODO
index 37dbeed456b1a2bcfbc8a31f375eec88fcd89c98..fcf73b3c4340655760087309641af44ec76b8f7a 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,8 +1,6 @@
 BEFORE REDIS 1.0.0-rc1
 
- * SPOP man page
  * Add number of keys for every DB in INFO
- * check 'server.dirty' everywere. Make it proprotional to the number of objects modified.
  * Cover most of the source code with test-redis.tcl
  * Remove tmp-.... files when saving child exits in the wrong way, to do so use tmp-pid.rdb as filename so that the parent can rebuild the file name just from the child pid.
 
diff --git a/redis.c b/redis.c
index 889a9e7385517d2fcbee7d18e44e31dc3d9b0615..b05d92ff676199dde0d305d99663256dbd8b1e39 100644 (file)
--- a/redis.c
+++ b/redis.c
@@ -734,8 +734,8 @@ static int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientD
         size = dictSlots(server.db[j].dict);
         used = dictSize(server.db[j].dict);
         vkeys = dictSize(server.db[j].expires);
-        if (!(loops % 5) && used > 0) {
-            redisLog(REDIS_DEBUG,"DB %d: %d keys (%d volatile) in %d slots HT.",j,used,vkeys,size);
+        if (!(loops % 5) && (used || vkeys)) {
+            redisLog(REDIS_DEBUG,"DB %d: %lld keys (%lld volatile) in %lld slots HT.",j,used,vkeys,size);
             /* dictPrintStats(server.dict); */
         }
     }
@@ -3602,6 +3602,7 @@ static void sortCommand(redisClient *c) {
 static void infoCommand(redisClient *c) {
     sds info;
     time_t uptime = time(NULL)-server.stat_starttime;
+    int j;
     
     info = sdscatprintf(sdsempty(),
         "redis_version:%s\r\n"
@@ -3642,6 +3643,16 @@ static void infoCommand(redisClient *c) {
             (int)(time(NULL)-server.master->lastinteraction)
         );
     }
+    for (j = 0; j < server.dbnum; j++) {
+        long long keys, vkeys;
+
+        keys = dictSize(server.db[j].dict);
+        vkeys = dictSize(server.db[j].expires);
+        if (keys || vkeys) {
+            info = sdscatprintf(info, "db%d: keys=%lld,expires=%lld\r\n",
+                j, keys, vkeys);
+        }
+    }
     addReplySds(c,sdscatprintf(sdsempty(),"$%d\r\n",sdslen(info)));
     addReplySds(c,info);
     addReply(c,shared.crlf);