mirror of https://mirror.osredm.com/root/redis.git
Expire key firstly and then notify keyspace event (#8830)
Modules event subscribers may get wrong things in notifyKeyspaceEvent callback, such as wrong number of keys, or be able to lookup this key. This commit changes the order to be like the one in evict.c. Cleanup: Since we know the key exists (it expires now), db*Delete is sure to return 1, so there's no need to check it's output (misleading).
This commit is contained in:
parent
b9d7d55b2c
commit
63acfe4b00
11
src/db.c
11
src/db.c
|
@ -1541,14 +1541,17 @@ int expireIfNeeded(redisDb *db, robj *key) {
|
|||
if (checkClientPauseTimeoutAndReturnIfPaused()) return 1;
|
||||
|
||||
/* Delete the key */
|
||||
if (server.lazyfree_lazy_expire) {
|
||||
dbAsyncDelete(db,key);
|
||||
} else {
|
||||
dbSyncDelete(db,key);
|
||||
}
|
||||
server.stat_expiredkeys++;
|
||||
propagateExpire(db,key,server.lazyfree_lazy_expire);
|
||||
notifyKeyspaceEvent(NOTIFY_EXPIRED,
|
||||
"expired",key,db->id);
|
||||
int retval = server.lazyfree_lazy_expire ? dbAsyncDelete(db,key) :
|
||||
dbSyncDelete(db,key);
|
||||
if (retval) signalModifiedKey(NULL,db,key);
|
||||
return retval;
|
||||
signalModifiedKey(NULL,db,key);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue