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->replica link guarantee operation ordering, everything * will be consistent even if we allow write operations against expiring * k
| 1964 | * will be consistent even if we allow write operations against expiring |
| 1965 | * keys. */ |
| 1966 | void propagateExpire(redisDb *db, robj *key, int lazy) { |
| 1967 | serverAssert(GlobalLocksAcquired()); |
| 1968 | |
| 1969 | robj *argv[2]; |
| 1970 | |
| 1971 | argv[0] = lazy ? shared.unlink : shared.del; |
| 1972 | argv[1] = key; |
| 1973 | incrRefCount(argv[0]); |
| 1974 | incrRefCount(argv[1]); |
| 1975 | |
| 1976 | /* If the master decided to expire a key we must propagate it to replicas no matter what.. |
| 1977 | * Even if module executed a command without asking for propagation. */ |
| 1978 | int prev_replication_allowed = g_pserver->replication_allowed; |
| 1979 | g_pserver->replication_allowed = 1; |
| 1980 | if (!g_pserver->fActiveReplica) // Active replicas do their own expiries, do not propogate |
| 1981 | propagate(cserver.delCommand,db->id,argv,2,PROPAGATE_AOF|PROPAGATE_REPL); |
| 1982 | g_pserver->replication_allowed = prev_replication_allowed; |
| 1983 | |
| 1984 | decrRefCount(argv[0]); |
| 1985 | decrRefCount(argv[1]); |
| 1986 | } |
| 1987 | |
| 1988 | void propagateSubkeyExpire(redisDb *db, int type, robj *key, robj *subkey) |
| 1989 | { |
no test coverage detected