From 040b0ade7dd9d30210ec89182bbe4d416416ed53 Mon Sep 17 00:00:00 2001
From: Hampus Wessman <hampus.wessman@gmail.com>
Date: Sun, 3 Jul 2011 12:18:44 +0200
Subject: [PATCH] Don't expire keys while loading AOF.

They will be expired (and a DEL will be logged) after the loading is done
instead.
---
 src/db.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/db.c b/src/db.c
index a02f3043..47994df2 100644
--- a/src/db.c
+++ b/src/db.c
@@ -476,6 +476,9 @@ int expireIfNeeded(redisDb *db, robj *key) {
 
     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;
+
     /* If we are running in the context of a slave, return ASAP:
      * the slave key expiration is controlled by the master that will
      * send us synthesized DEL operations for expired keys.
@@ -513,7 +516,7 @@ void expireGenericCommand(redisClient *c, robj *key, robj *param, long offset) {
         addReply(c,shared.czero);
         return;
     }
-    if (seconds <= 0) {
+    if (seconds <= 0 && !server.loading) {
         if (dbDelete(c->db,key)) server.dirty++;
         addReply(c, shared.cone);
         signalModifiedKey(c->db,key);
-- 
2.45.2