From 5ddd507624aad7d07558e684a962b7505214ae74 Mon Sep 17 00:00:00 2001 From: "zhaozhao.zz" Date: Fri, 19 Oct 2018 18:16:29 +0800 Subject: [PATCH] if we read a expired key, misses++ --- src/db.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/db.c b/src/db.c index ec92a2b4..8b7ad521 100644 --- a/src/db.c +++ b/src/db.c @@ -102,7 +102,10 @@ robj *lookupKeyReadWithFlags(redisDb *db, robj *key, int flags) { /* Key expired. If we are in the context of a master, expireIfNeeded() * returns 0 only when the key does not exist at all, so it's safe * to return NULL ASAP. */ - if (server.masterhost == NULL) return NULL; + if (server.masterhost == NULL) { + server.stat_keyspace_misses++; + return NULL; + } /* However if we are in the context of a slave, expireIfNeeded() will * not really try to expire the key, it only returns information @@ -121,6 +124,7 @@ robj *lookupKeyReadWithFlags(redisDb *db, robj *key, int flags) { server.current_client->cmd && server.current_client->cmd->flags & CMD_READONLY) { + server.stat_keyspace_misses++; return NULL; } }