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

Function LFULogIncr

app/redis-6.2.6/src/evict.c:298–306  ·  view source on GitHub ↗

Logarithmically increment a counter. The greater is the current counter value * the less likely is that it gets really implemented. Saturate it at 255. */

Source from the content-addressed store, hash-verified

296/* Logarithmically increment a counter. The greater is the current counter value
297 * the less likely is that it gets really implemented. Saturate it at 255. */
298uint8_t LFULogIncr(uint8_t counter) {
299 if (counter == 255) return 255;
300 double r = (double)rand()/RAND_MAX;
301 double baseval = counter - LFU_INIT_VAL;
302 if (baseval < 0) baseval = 0;
303 double p = 1.0/(baseval*server.lfu_log_factor+1);
304 if (r < p) counter++;
305 return counter;
306}
307
308/* If the object decrement time is reached decrement the LFU counter but
309 * do not update LFU fields of the object, we update the access time

Callers 1

updateLFUFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected