007 Redis内存淘汰机制,引出LRU算法问题,简述LRU在常用框架中的使用

读读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限流模块初探

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值