summaryrefslogtreecommitdiff
path: root/src/expire.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/expire.c')
-rw-r--r--src/expire.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/expire.c b/src/expire.c
index 30a27193d..f2d135e2b 100644
--- a/src/expire.c
+++ b/src/expire.c
@@ -475,6 +475,16 @@ void flushSlaveKeysWithExpireList(void) {
}
}
+int checkAlreadyExpired(long long when) {
+ /* EXPIRE with negative TTL, or EXPIREAT with a timestamp into the past
+ * should never be executed as a DEL when load the AOF or in the context
+ * of a slave instance.
+ *
+ * Instead we add the already expired key to the database with expire time
+ * (possibly in the past) and wait for an explicit DEL from the master. */
+ return (when <= mstime() && !server.loading && !server.masterhost);
+}
+
/*-----------------------------------------------------------------------------
* Expires Commands
*----------------------------------------------------------------------------*/
@@ -502,13 +512,7 @@ void expireGenericCommand(client *c, long long basetime, int unit) {
return;
}
- /* EXPIRE with negative TTL, or EXPIREAT with a timestamp into the past
- * should never be executed as a DEL when load the AOF or in the context
- * of a slave instance.
- *
- * Instead we take the other branch of the IF statement setting an expire
- * (possibly in the past) and wait for an explicit DEL from the master. */
- if (when <= mstime() && !server.loading && !server.masterhost) {
+ if (checkAlreadyExpired(when)) {
robj *aux;
int deleted = server.lazyfree_lazy_expire ? dbAsyncDelete(c->db,key) :