diff options
author | antirez <antirez@gmail.com> | 2016-07-18 14:19:38 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2016-07-18 14:19:38 +0200 |
commit | dbce190ad018fc757d9c494952531db31eaac700 (patch) | |
tree | 29288ae55f701a2a04c59aade6b641bb45eb16ee /src/evict.c | |
parent | a8e2d0849e2a40f8bec14cd1b7ff170c17f772c3 (diff) | |
download | redis-dbce190ad018fc757d9c494952531db31eaac700.tar.gz |
LFU: Fix bugs in frequency decay code.
Diffstat (limited to 'src/evict.c')
-rw-r--r-- | src/evict.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/evict.c b/src/evict.c index b48892b41..3025b3e9b 100644 --- a/src/evict.c +++ b/src/evict.c @@ -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; |