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

Function evictionPoolPopulate

src/evict.cpp:234–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232 * right. */
233
234int evictionPoolPopulate(int dbid, redisDb *db, bool fVolatile, struct evictionPoolEntry *pool)
235{
236 int returnCount = 0;
237 dictEntry **samples = (dictEntry**)alloca(g_pserver->maxmemory_samples * sizeof(dictEntry*));
238 int count = dictGetSomeKeys(db->dictUnsafeKeyOnly(),samples,g_pserver->maxmemory_samples);
239 for (int j = 0; j < count; j++) {
240 robj *o = (robj*)dictGetVal(samples[j]);
241 // If the object is in second tier storage we don't need to evict it (since it already is)
242 if (o != nullptr)
243 {
244 if (!fVolatile || o->FExpires()) {
245 processEvictionCandidate(dbid, (sds)dictGetKey(samples[j]), o, &o->expire, pool);
246 ++returnCount;
247 }
248 }
249 }
250 return returnCount;
251}
252
253/* ----------------------------------------------------------------------------
254 * LFU (Least Frequently Used) implementation.

Callers 1

performEvictionsFunction · 0.85

Calls 4

dictGetSomeKeysFunction · 0.85
processEvictionCandidateFunction · 0.85
dictUnsafeKeyOnlyMethod · 0.80
FExpiresMethod · 0.80

Tested by

no test coverage detected