redis内存回收
1.定时过期expilre expire key TTL 10定时器 主动淘汰 2.惰性过期 被动淘汰 3getCommand expireIfNeed() 设置内存上线 set memory 上线 activeExpireCycle() redis使用了 惰性过期 + 定期过期 达到了最大内存上线后根据内存淘汰规则 # volatile-lru -> remove the key with an expire set using an LRU algorithm # allkeys-lru -> remove any key according to the LRU algorithm # volatile-random -> remove a random key with an expire set # allkeys-random -> remove a random key, any key # volatile-ttl -> remove the key with the nearest expire time (minor TTL) # noeviction -> don't expire at all, just return an error on write operations 不在接收新的指令存进内存
volatile-lru:根据LRU算法生成的过期时间来删除。 allkeys-lru:根据LRU算法删除任何key。 volatile-lfu:从所有配置了过期时间的键中驱逐使用频率最少的键 allkeys-lfu:从所有键中驱逐使用频率最少的键 volatile-random:根据过期设置来随机删除key。 allkeys-random:无差别随机删。 volatile-ttl:根据最近过期时间来删除(辅以TTL) noeviction:谁也不删,直接在写操作时返回错误。
一点点学习,一丝丝进步。不懈怠,才不会被时代淘汰