]> git.saurik.com Git - redis.git/blobdiff - src/db.c
Only incremnet stats for key miss/hit when the key is semantically accessed in read...
[redis.git] / 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) {