summaryrefslogtreecommitdiff
path: root/src/expire.c
diff options
context:
space:
mode:
authorItamar Haber <itamar@redislabs.com>2020-07-10 16:22:58 +0300
committerGitHub <noreply@github.com>2020-07-10 16:22:58 +0300
commita6504a16f70511c06bd5460b7cdfee6247cb09a6 (patch)
treeed0a47f5c181e8bfc046d0d9bd6b7da64cf98e0a /src/expire.c
parent91d309681cf9db8c3b8d4f2d828c336cff661efb (diff)
parentd5648d617e1ed5b9cfa575ad412bc9d450b16afd (diff)
downloadredis-conduct.tar.gz
Merge branch 'unstable' into conductconduct
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) :