summaryrefslogtreecommitdiff
path: root/src/db.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2016-07-15 12:12:52 +0200
committerantirez <antirez@gmail.com>2016-07-15 12:12:58 +0200
commit5d07984c5d48d6253ea5884d69da3f06cdc90f1b (patch)
treec69a4d5043e308dbcf5b8509d2ddc86b85cbcd16 /src/db.c
parentada70c7c532f8a1d1fe946dd7663c9e48d834a02 (diff)
downloadredis-5d07984c5d48d6253ea5884d69da3f06cdc90f1b.tar.gz
LFU: Redis object level implementation.
Implementation of LFU maxmemory policy for anything related to Redis objects. Still no actual eviction implemented.
Diffstat (limited to 'src/db.c')
-rw-r--r--src/db.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/db.c b/src/db.c
index 03615fd34..b00227d81 100644
--- a/src/db.c
+++ b/src/db.c
@@ -53,7 +53,13 @@ robj *lookupKey(redisDb *db, robj *key, int flags) {
server.aof_child_pid == -1 &&
!(flags & LOOKUP_NOTOUCH))
{
- val->lru = LRU_CLOCK();
+ if (server.maxmemory_policy & MAXMEMORY_FLAG_LFU) {
+ unsigned long ldt = val->lru >> 8;
+ unsigned long counter = LFULogIncr(val->lru & 255);
+ val->lru = (ldt << 8) | counter;
+ } else {
+ val->lru = LRU_CLOCK();
+ }
}
return val;
} else {