redis的淘汰算法持久化
Redis的淘汰策略 如果你的 Redis 只能存8G数据,你写了11G,那么 Redis 会怎么淘汰那3G数据呢? redis.conf 中的过期淘汰配置 看下源码的配置 # MAXMEMORY POLICY: how Redis will select what to remove when maxmemory # is reached. You can select among five behaviors: #最大内存策略:当到达最大使用内存时,你可以在下面5种行为中选择,Redis如何选择淘汰数据库键 #当内存不足以容纳新写入数据时 # volatile-lru -> remove the key with an expire set using an LRU algorithm # volatile-lru :在设置了过期时间的键空间中,移除最近最少使用的key。这种情况一般是把 redis 既当缓存,又做持久化存储的时候才用。 # allkeys-lru -> remove any key according to the LRU algorithm # allkeys-lru : 移除最近最少使用的key (推荐) # volatile-random -> remove a random key with an expire set # volatile