LFU: Initial naive eviction cycle.

It is possible to get better results by using the pool like in the LRU
case. Also from tests during the morning I believe the current
implementation has issues in the frequency decay function that should
decrease the counter at periodic intervals.
This commit is contained in:
antirez
2016-07-18 13:49:31 +02:00
parent 24dd4a8f04
commit a8e2d0849e
3 changed files with 49 additions and 4 deletions

View File

@ -175,7 +175,14 @@ void dbOverwrite(redisDb *db, robj *key, robj *val) {
dictEntry *de = dictFind(db->dict,key->ptr);
serverAssertWithInfo(NULL,key,de != NULL);
dictReplace(db->dict, key->ptr, val);
if (server.maxmemory_policy & MAXMEMORY_FLAG_LFU) {
robj *old = dictGetVal(de);
int saved_lru = old->lru;
dictReplace(db->dict, key->ptr, val);
val->lru = saved_lru;
} else {
dictReplace(db->dict, key->ptr, val);
}
}
/* High level Set operation. This function can be used in order to set