Track keys that received an EXPIRE or similar command in the context * of a writable slave. */
| 416 | /* Track keys that received an EXPIRE or similar command in the context |
| 417 | * of a writable slave. */ |
| 418 | void rememberSlaveKeyWithExpire(redisDb *db, robj *key) { |
| 419 | if (slaveKeysWithExpire == NULL) { |
| 420 | static dictType dt = { |
| 421 | dictSdsHash, /* hash function */ |
| 422 | NULL, /* key dup */ |
| 423 | NULL, /* val dup */ |
| 424 | dictSdsKeyCompare, /* key compare */ |
| 425 | dictSdsDestructor, /* key destructor */ |
| 426 | NULL, /* val destructor */ |
| 427 | NULL /* allow to expand */ |
| 428 | }; |
| 429 | slaveKeysWithExpire = dictCreate(&dt,NULL); |
| 430 | } |
| 431 | if (db->id > 63) return; |
| 432 | |
| 433 | dictEntry *de = dictAddOrFind(slaveKeysWithExpire,key->ptr); |
| 434 | /* If the entry was just created, set it to a copy of the SDS string |
| 435 | * representing the key: we don't want to need to take those keys |
| 436 | * in sync with the main DB. The keys will be removed by expireSlaveKeys() |
| 437 | * as it scans to find keys to remove. */ |
| 438 | if (de->key == key->ptr) { |
| 439 | de->key = sdsdup(key->ptr); |
| 440 | dictSetUnsignedIntegerVal(de,0); |
| 441 | } |
| 442 | |
| 443 | uint64_t dbids = dictGetUnsignedIntegerVal(de); |
| 444 | dbids |= (uint64_t)1 << db->id; |
| 445 | dictSetUnsignedIntegerVal(de,dbids); |
| 446 | } |
| 447 | |
| 448 | /* Return the number of keys we are tracking. */ |
| 449 | size_t getSlaveKeyWithExpireCount(void) { |
no test coverage detected