number of keys info in INFO command thanks to Diego Rosario Brogna

This commit is contained in:
antirez 2009-06-14 23:34:25 +02:00
parent 7492bbe9f5
commit c3cb078d46
2 changed files with 13 additions and 4 deletions

2
TODO
View File

@ -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.

15
redis.c
View File

@ -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);