summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2012-02-01 21:47:41 +0100
committerantirez <antirez@gmail.com>2012-02-01 21:51:20 +0100
commitb80b1c5914435c3a013cfe9b19e39f9de35ab06e (patch)
treea1bd47d45cdc0928df2ab7a58cdc9497f7762781 /src
parentc17947287afe5b081400679dbe9882cd4e95776b (diff)
downloadredis-b80b1c5914435c3a013cfe9b19e39f9de35ab06e.tar.gz
Only incremnet stats for key miss/hit when the key is semantically accessed in read-only.
Diffstat (limited to 'src')
-rw-r--r--src/db.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/db.c b/src/db.c
index 3ff7113b7..fc366b07e 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) {