]> git.saurik.com Git - redis.git/commitdiff
Only incremnet stats for key miss/hit when the key is semantically accessed in read...
authorantirez <antirez@gmail.com>
Wed, 1 Feb 2012 20:47:41 +0000 (21:47 +0100)
committerantirez <antirez@gmail.com>
Wed, 1 Feb 2012 20:51:20 +0000 (21:51 +0100)
src/db.c

index 3ff7113b7447159501818b8a2bb11e63a47beb3a..fc366b07ed2626ecd746ef0f166195bb0588302e 100644 (file)
--- 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) {