mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 00:28:26 -05:00
don't process EXPIRE with negative TTL or EXPIREAT with time in the past if we are a slave too (see http://groups.google.com/group/redis-db/browse_thread/thread/5a931fefb88b16d5). Also propagate it as DEL.
This commit is contained in:
parent
040b0ade7d
commit
812ecc8b10
20
src/db.c
20
src/db.c
@ -516,10 +516,24 @@ void expireGenericCommand(redisClient *c, robj *key, robj *param, long offset) {
|
|||||||
addReply(c,shared.czero);
|
addReply(c,shared.czero);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (seconds <= 0 && !server.loading) {
|
/* EXPIRE with negative TTL, or EXPIREAT with a timestamp into the past
|
||||||
if (dbDelete(c->db,key)) server.dirty++;
|
* should never be executed as a DEL when load the AOF or in the context
|
||||||
addReply(c, shared.cone);
|
* 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 (seconds <= 0 && !server.loading && !server.masterhost) {
|
||||||
|
robj *aux;
|
||||||
|
|
||||||
|
redisAssert(dbDelete(c->db,key));
|
||||||
|
server.dirty++;
|
||||||
|
|
||||||
|
/* Replicate/AOF this as an explicit DEL. */
|
||||||
|
aux = createStringObject("DEL",3);
|
||||||
|
rewriteClientCommandVector(c,2,aux,key);
|
||||||
|
decrRefCount(aux);
|
||||||
signalModifiedKey(c->db,key);
|
signalModifiedKey(c->db,key);
|
||||||
|
addReply(c, shared.cone);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
time_t when = time(NULL)+seconds;
|
time_t when = time(NULL)+seconds;
|
||||||
|
Loading…
Reference in New Issue
Block a user