summaryrefslogtreecommitdiff
path: root/src/db.c
diff options
context:
space:
mode:
authorShuning <36000971+lsn1994@users.noreply.github.com>2022-10-18 18:55:49 +0800
committerGitHub <noreply@github.com>2022-10-18 13:55:49 +0300
commit20d286f77eabccd657be66d3193556ea7ebe4d26 (patch)
tree818f77d546e210f02336b7495e874c6318460e9a /src/db.c
parentba1f09d3fecc4c1c52a1b7e17dea207939a5843d (diff)
downloadredis-20d286f77eabccd657be66d3193556ea7ebe4d26.tar.gz
keyIsExpired checks server.loading before calling getExpire (#11393)
Seems excessive to call getExpire if we don't need it. This can maybe have some speedup on AOF file loading (saving a dictFind call) Co-authored-by: lvshuning <lvshuning@meituan.com>
Diffstat (limited to 'src/db.c')
-rw-r--r--src/db.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/db.c b/src/db.c
index b7b4dc390..63705cd01 100644
--- a/src/db.c
+++ b/src/db.c
@@ -1612,14 +1612,14 @@ void propagateDeletion(redisDb *db, robj *key, int lazy) {
/* Check if the key is expired. */
int keyIsExpired(redisDb *db, robj *key) {
+ /* Don't expire anything while loading. It will be done later. */
+ if (server.loading) return 0;
+
mstime_t when = getExpire(db,key);
mstime_t now;
if (when < 0) return 0; /* No expire for this key */
- /* Don't expire anything while loading. It will be done later. */
- if (server.loading) return 0;
-
now = commandTimeSnapshot();
/* The key expired if the current (virtual or real) time is greater