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

Function LFUDecrAndReturn

src/evict.cpp:329–336  ·  view source on GitHub ↗

If the object decrement time is reached decrement the LFU counter but * do not update LFU fields of the object, we update the access time * and counter in an explicit way when the object is really accessed. * And we will times halve the counter according to the times of * elapsed time than g_pserver->lfu_decay_time. * Return the object frequency counter. * * This function is used in order t

Source from the content-addressed store, hash-verified

327 * to fit: as we check for the candidate, we incrementally decrement the
328 * counter of the scanned objects if needed. */
329unsigned long LFUDecrAndReturn(robj_roptr o) {
330 unsigned long ldt = o->lru >> 8;
331 unsigned long counter = o->lru & 255;
332 unsigned long num_periods = g_pserver->lfu_decay_time ? LFUTimeElapsed(ldt) / g_pserver->lfu_decay_time : 0;
333 if (num_periods)
334 counter = (num_periods > counter) ? 0 : counter - num_periods;
335 return counter;
336}
337
338unsigned long getClientReplicationBacklogSharedUsage(client *c);
339

Callers 5

updateLFUFunction · 0.85
getIdleFunction · 0.85
rdbSaveKeyValuePairFunction · 0.85
objectCommandFunction · 0.85
RM_GetLFUFunction · 0.85

Calls 1

LFUTimeElapsedFunction · 0.85

Tested by

no test coverage detected