3 ms·
Redis's LRU eviction is actually 3-random by default. It does not support true/full LRU. Edit: this is clearer - https://redis.io/topics/lru-cache#approximated
by BillinghamJ 10y ago
Redis's LRU eviction is actually 3-random by default. It does not support true/full LRU.
Edit: this is clearer - https://redis.io/topics/lru-cache#approximated-lru-algorithm https://redis.io/topics/lru-cache#approximated-lru-algorithm
Excerpt from https://raw.githubusercontent.com/antirez/redis/2.8/redis.conf https://raw.githubusercontent.com/antirez/redis/2.8/redis.co...
# LRU and minimal TTL algorithms are not precise algorithms but approximated
# algorithms (in order to save memory), so you can select as well the sample
# size to check. For instance for default Redis will check three keys and
# pick the one that was used less recently, you can change the sample size
# using the following configuration directive.
#
# maxmemory-samples 3
- antirez 10y agoRedis does a much better thing in recent versions: it uses a few samples per iteration, but instead of discarding the accumulated data, it takes a pool of good candidates to re-check in the next iteration, so the approximation to LRU is very close compared to vanilla "among 3" algorithms. Moreover since the performance was improved, now the default is to look at 5 items making the algorithm better. More than the precision of LRU itself, I'm more intrigued with the potential improvements that LFU (Redis >= 4.0) can provide, but being 4.0 just in RC state, most users are currently just using LRU.
- BillinghamJ 10y agoNice! Thanks for the in-depth explanation :)