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
| 1463 | * will be consistent even if we allow write operations against expiring |
| 1464 | * keys. */ |
| 1465 | void 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. */ |
| 1485 | int keyIsExpired(redisDb *db, robj *key) { |
no test coverage detected