读读Redis的官网,学第一手的资料:Redid官方文档地址
Redis中国-文档网址:Redis中国-文档地址
或者看看书《Redis 深度历险: 核心原理和应用实践》
1、之前整理过2篇关于LRU的博客
Java多线程高并发专题的文章:
024 Java实现LRU(Least recently used,最近最少使用)算法 之 LinkedHashMap
MySQL专题的文章:
022 由MySQL的Buffer Pool想到的LRU算法用在哪些地方,LRU算法如何实现
2、Redis官网中关于LRU的描述
Approximated LRU algorithm
Redis LRU algorithm is not an exact implementation. This means that Redis is not able to
pick the best candidate for eviction, that is, the access that was accessed the furthest
in the past. Instead it will try to run an approximation of the LRU algorithm,
by sampling a small number of keys, and evicting the one that is
the best (with the oldest access time) among the sampled keys.
However, since Redis 3.0 the algorithm was improved to also take a pool of
good candidates for eviction. This improved the performance of the algorithm,
making it able to approximate more closely the behavior of a real LRU algorithm.
官网中说Redis用的是近似LRU算法。
3、LRU算法的经典实用场合
3.1 Redis
既没有定期删除也没有惰性删除的数据,走Key eviction(其中有一种,allkeys-lru: Keeps most recently used keys; removes least recently used (LRU) keys)
3.2 MySQL中的Buffer Pool
3.3 Nginx中请求速率限流模块
ngx_http_limit_req_module中,详细的参见地址:Nginx限流模块初探