MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / activeExpireCycleExpireFullKey

Function activeExpireCycleExpireFullKey

src/expire.cpp:47–64  ·  view source on GitHub ↗

Helper function for the activeExpireCycle() function. * This function will try to expire the key that is stored in the hash table * entry 'de' of the 'expires' hash table of a Redis database. * * If the key is found to be expired, it is removed from the database and * 1 is returned. Otherwise no operation is performed and 0 is returned. * * When a key is expired, g_pserver->stat_expiredkeys

Source from the content-addressed store, hash-verified

45 * The parameter 'now' is the current time in milliseconds as is passed
46 * to the function to avoid too many gettimeofday() syscalls. */
47void activeExpireCycleExpireFullKey(redisDb *db, const char *key) {
48 robj *keyobj = createStringObject(key,sdslen(key));
49 mstime_t expire_latency;
50
51 propagateExpire(db,keyobj,g_pserver->lazyfree_lazy_expire);
52 latencyStartMonitor(expire_latency);
53 if (g_pserver->lazyfree_lazy_expire)
54 dbAsyncDelete(db,keyobj);
55 else
56 dbSyncDelete(db,keyobj);
57 latencyEndMonitor(expire_latency);
58 latencyAddSampleIfNeeded("expire-del",expire_latency);
59 notifyKeyspaceEvent(NOTIFY_EXPIRED,
60 "expired",keyobj,db->id);
61 signalModifiedKey(NULL, db, keyobj);
62 decrRefCount(keyobj);
63 g_pserver->stat_expiredkeys++;
64}
65
66/*-----------------------------------------------------------------------------
67 * Incremental collection of expired keys.

Callers 1

activeExpireCycleExpireFunction · 0.85

Calls 8

sdslenFunction · 0.85
propagateExpireFunction · 0.85
dbAsyncDeleteFunction · 0.85
dbSyncDeleteFunction · 0.85
notifyKeyspaceEventFunction · 0.85
signalModifiedKeyFunction · 0.85
decrRefCountFunction · 0.85
createStringObjectFunction · 0.70

Tested by

no test coverage detected