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

Function rememberSlaveKeyWithExpire

app/redis-6.2.6/src/expire.c:418–446  ·  view source on GitHub ↗

Track keys that received an EXPIRE or similar command in the context * of a writable slave. */

Source from the content-addressed store, hash-verified

416/* Track keys that received an EXPIRE or similar command in the context
417 * of a writable slave. */
418void 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. */
449size_t getSlaveKeyWithExpireCount(void) {

Callers 1

setExpireFunction · 0.85

Calls 3

dictAddOrFindFunction · 0.85
sdsdupFunction · 0.85
dictCreateFunction · 0.70

Tested by

no test coverage detected