Track keys that received an EXPIRE or similar command in the context * of a writable replica. */
| 665 | /* Track keys that received an EXPIRE or similar command in the context |
| 666 | * of a writable replica. */ |
| 667 | void rememberSlaveKeyWithExpire(redisDb *db, robj *key) { |
| 668 | if (slaveKeysWithExpire == NULL) { |
| 669 | static dictType dt = { |
| 670 | dictSdsHash, /* hash function */ |
| 671 | NULL, /* key dup */ |
| 672 | NULL, /* val dup */ |
| 673 | dictSdsKeyCompare, /* key compare */ |
| 674 | dictSdsDestructor, /* key destructor */ |
| 675 | NULL, /* val destructor */ |
| 676 | NULL /* allow to expand */ |
| 677 | }; |
| 678 | slaveKeysWithExpire = dictCreate(&dt,NULL); |
| 679 | } |
| 680 | if (db->id > 63) return; |
| 681 | |
| 682 | dictEntry *de = dictAddOrFind(slaveKeysWithExpire,ptrFromObj(key)); |
| 683 | /* If the entry was just created, set it to a copy of the SDS string |
| 684 | * representing the key: we don't want to need to take those keys |
| 685 | * in sync with the main DB. The keys will be removed by expireSlaveKeys() |
| 686 | * as it scans to find keys to remove. */ |
| 687 | if (de->key == ptrFromObj(key)) { |
| 688 | de->key = sdsdup(szFromObj(key)); |
| 689 | dictSetUnsignedIntegerVal(de,0); |
| 690 | } |
| 691 | |
| 692 | uint64_t dbids = dictGetUnsignedIntegerVal(de); |
| 693 | dbids |= (uint64_t)1 << db->id; |
| 694 | dictSetUnsignedIntegerVal(de,dbids); |
| 695 | } |
| 696 | |
| 697 | /* Return the number of keys we are tracking. */ |
| 698 | size_t getSlaveKeyWithExpireCount(void) { |
no test coverage detected