From: antirez Date: Wed, 1 Feb 2012 20:47:41 +0000 (+0100) Subject: Only incremnet stats for key miss/hit when the key is semantically accessed in read... X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/b80b1c5914435c3a013cfe9b19e39f9de35ab06e?ds=sidebyside Only incremnet stats for key miss/hit when the key is semantically accessed in read-only. --- diff --git a/src/db.c b/src/db.c index 3ff7113b..fc366b07 100644 --- a/src/db.c +++ b/src/db.c @@ -42,17 +42,22 @@ robj *lookupKey(redisDb *db, robj *key) { * a copy on write madness. */ if (server.rdb_child_pid == -1 && server.aof_child_pid == -1) val->lru = server.lruclock; - server.stat_keyspace_hits++; return val; } else { - server.stat_keyspace_misses++; return NULL; } } robj *lookupKeyRead(redisDb *db, robj *key) { + robj *val; + expireIfNeeded(db,key); - return lookupKey(db,key); + val = lookupKey(db,key); + if (val == NULL) + server.stat_keyspace_misses++; + else + server.stat_keyspace_hits++; + return val; } robj *lookupKeyWrite(redisDb *db, robj *key) {