added keyspace_hits and keyspace_misses fields in INFO output

This commit is contained in:
antirez 2010-10-15 12:19:21 +02:00
parent a36879293d
commit 53eeeaff08
3 changed files with 15 additions and 5 deletions

View File

@ -34,8 +34,10 @@ robj *lookupKey(redisDb *db, robj *key) {
if (notify) handleClientsBlockedOnSwappedKey(db,key); if (notify) handleClientsBlockedOnSwappedKey(db,key);
} }
} }
server.stat_keyspace_hits++;
return val; return val;
} else { } else {
server.stat_keyspace_misses++;
return NULL; return NULL;
} }
} }

View File

@ -823,6 +823,8 @@ void initServer() {
server.stat_numconnections = 0; server.stat_numconnections = 0;
server.stat_expiredkeys = 0; server.stat_expiredkeys = 0;
server.stat_starttime = time(NULL); server.stat_starttime = time(NULL);
server.stat_keyspace_misses = 0;
server.stat_keyspace_hits = 0;
server.unixtime = time(NULL); server.unixtime = time(NULL);
aeCreateTimeEvent(server.el, 1, serverCron, NULL, NULL); aeCreateTimeEvent(server.el, 1, serverCron, NULL, NULL);
if (aeCreateFileEvent(server.el, server.fd, AE_READABLE, if (aeCreateFileEvent(server.el, server.fd, AE_READABLE,
@ -1190,6 +1192,8 @@ sds genRedisInfoString(void) {
"total_connections_received:%lld\r\n" "total_connections_received:%lld\r\n"
"total_commands_processed:%lld\r\n" "total_commands_processed:%lld\r\n"
"expired_keys:%lld\r\n" "expired_keys:%lld\r\n"
"keyspace_hits:%lld\r\n"
"keyspace_misses:%lld\r\n"
"hash_max_zipmap_entries:%zu\r\n" "hash_max_zipmap_entries:%zu\r\n"
"hash_max_zipmap_value:%zu\r\n" "hash_max_zipmap_value:%zu\r\n"
"pubsub_channels:%ld\r\n" "pubsub_channels:%ld\r\n"
@ -1222,6 +1226,8 @@ sds genRedisInfoString(void) {
server.stat_numconnections, server.stat_numconnections,
server.stat_numcommands, server.stat_numcommands,
server.stat_expiredkeys, server.stat_expiredkeys,
server.stat_keyspace_hits,
server.stat_keyspace_misses,
server.hash_max_zipmap_entries, server.hash_max_zipmap_entries,
server.hash_max_zipmap_value, server.hash_max_zipmap_value,
dictSize(server.pubsub_channels), dictSize(server.pubsub_channels),

View File

@ -357,12 +357,14 @@ struct redisServer {
aeEventLoop *el; aeEventLoop *el;
int cronloops; /* number of times the cron function run */ int cronloops; /* number of times the cron function run */
list *objfreelist; /* A list of freed objects to avoid malloc() */ list *objfreelist; /* A list of freed objects to avoid malloc() */
time_t lastsave; /* Unix time of last save succeeede */ time_t lastsave; /* Unix time of last save succeeede */
/* Fields used only for stats */ /* Fields used only for stats */
time_t stat_starttime; /* server start time */ time_t stat_starttime; /* server start time */
long long stat_numcommands; /* number of processed commands */ long long stat_numcommands; /* number of processed commands */
long long stat_numconnections; /* number of connections received */ long long stat_numconnections; /* number of connections received */
long long stat_expiredkeys; /* number of expired keys */ long long stat_expiredkeys; /* number of expired keys */
long long stat_keyspace_hits; /* number of successful lookups of keys */
long long stat_keyspace_misses; /* number of failed lookups of keys */
/* Configuration */ /* Configuration */
int verbosity; int verbosity;
int glueoutputbuf; int glueoutputbuf;