redis 内存淘汰机制

1、redis 内存淘汰机制:MySQL里有2000w数据,Redis中只存20w的数据,如何保证Redis中的数据都是热点数据?

http://download.redis.io/redis-stable/redis.conf

redis 提供 6种数据淘汰策略:

1. volatile-lru:从已设置过期时间的数据集(server.db[i].expires)中挑选最近最少使用的数据淘汰。

2. volatile-ttl:从已设置过期时间的数据集(server.db[i].expires)中挑选将要过期的数据淘汰。

3. volatile-random:从已设置过期时间的数据集(server.db[i].expires)中任意选择数据淘汰。

4. allkeys-lru:当内存不足以容纳新写入数据时,在键空间中,移除最近最少使用的key(这个是最常用的)。

5. allkeys-random:从数据集(server.db[i].dict)中任意选择数据淘汰。

6. no-eviction:禁止驱逐数据,也就是说当内存不足以容纳新写入数据时,新写入操作会报错。

原文地址:https://www.cnblogs.com/guoyu1/p/12264750.html