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

Function activeExpireCycleTryExpire

app/redis-6.2.6/src/expire.c:54–65  ·  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, server.stat_expiredkeys is

Source from the content-addressed store, hash-verified

52 * The parameter 'now' is the current time in milliseconds as is passed
53 * to the function to avoid too many gettimeofday() syscalls. */
54int activeExpireCycleTryExpire(redisDb *db, dictEntry *de, long long now) {
55 long long t = dictGetSignedIntegerVal(de);
56 if (now > t) {
57 sds key = dictGetKey(de);
58 robj *keyobj = createStringObject(key,sdslen(key));
59 deleteExpiredKeyAndPropagate(db,keyobj);
60 decrRefCount(keyobj);
61 return 1;
62 } else {
63 return 0;
64 }
65}
66
67/* Try to expire a few timed out keys. The algorithm used is adaptive and
68 * will use few CPU cycles if there are few expiring keys, otherwise

Callers 2

activeExpireCycleFunction · 0.85
expireSlaveKeysFunction · 0.85

Calls 4

sdslenFunction · 0.85
decrRefCountFunction · 0.85
createStringObjectFunction · 0.70

Tested by

no test coverage detected