MCPcopy Create free account
hub / github.com/F-Stack/f-stack / propagateExpire

Function propagateExpire

app/redis-6.2.6/src/db.c:1465–1482  ·  view source on GitHub ↗

Propagate expires into slaves and the AOF file. * When a key expires in the master, a DEL operation for this key is sent * to all the slaves and the AOF file if enabled. * * This way the key expiry is centralized in one place, and since both * AOF and the master->slave link guarantee operation ordering, everything * will be consistent even if we allow write operations against expiring * key

Source from the content-addressed store, hash-verified

1463 * will be consistent even if we allow write operations against expiring
1464 * keys. */
1465void propagateExpire(redisDb *db, robj *key, int lazy) {
1466 robj *argv[2];
1467
1468 argv[0] = lazy ? shared.unlink : shared.del;
1469 argv[1] = key;
1470 incrRefCount(argv[0]);
1471 incrRefCount(argv[1]);
1472
1473 /* If the master decided to expire a key we must propagate it to replicas no matter what..
1474 * Even if module executed a command without asking for propagation. */
1475 int prev_replication_allowed = server.replication_allowed;
1476 server.replication_allowed = 1;
1477 propagate(server.delCommand,db->id,argv,2,PROPAGATE_AOF|PROPAGATE_REPL);
1478 server.replication_allowed = prev_replication_allowed;
1479
1480 decrRefCount(argv[0]);
1481 decrRefCount(argv[1]);
1482}
1483
1484/* Check if the key is expired. */
1485int keyIsExpired(redisDb *db, robj *key) {

Callers 2

performEvictionsFunction · 0.85

Calls 3

incrRefCountFunction · 0.85
propagateFunction · 0.85
decrRefCountFunction · 0.85

Tested by

no test coverage detected