Commit dbce190a authored by antirez's avatar antirez
Browse files

LFU: Fix bugs in frequency decay code.

parent a8e2d084
......@@ -264,7 +264,7 @@ unsigned long LFUGetTimeInMinutes(void) {
* exactly once. */
unsigned long LFUTimeElapsed(unsigned long ldt) {
unsigned long now = LFUGetTimeInMinutes();
if (now > ldt) return now-ldt;
if (now >= ldt) return now-ldt;
return 65535-ldt+now;
}
......@@ -291,7 +291,7 @@ uint8_t LFULogIncr(uint8_t counter) {
unsigned long LFUDecrAndReturn(robj *o) {
unsigned long ldt = o->lru >> 8;
unsigned long counter = o->lru & 255;
if (LFUTimeElapsed(ldt) > LFU_DECR_INTERVAL && counter) {
if (LFUTimeElapsed(ldt) >= LFU_DECR_INTERVAL && counter) {
if (counter > LFU_INIT_VAL*2) {
counter /= 2;
if (counter < LFU_INIT_VAL*2) counter = LFU_INIT_VAL*2;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment