redis 數據淘汰策略
volatile-lru:從已設置過期的數據集中挑選最近最少使用的淘汰
volatile-ttl:從已設置過期的數據集中挑選將要過期的數據淘汰
volatile-random:從已設置過期的數據集中任意挑選數據淘汰
allkeys-lru:從數據集中挑選最近最少使用的數據淘汰
allkeys-random:從數據集中任意挑選數據淘汰
noenviction:禁止淘汰數據
redis淘汰數據時還會同步到aof中、從機
配置文件
# maxmemory <bytes>
# 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
# The default is:
# maxmemory-policy noeviction
我們可以設置maxmemory <bytes>,當數據達到限定大小后,會選擇配置的策略淘汰數據
可設置內存最大使用量,超出時淘汰, 淘汰策略。
策略
描述
volatile-lru
從已設置過期時間的數據集中挑選最近最少使用的數據淘汰
volatile-ttl
從已設置過期時間的數據集中挑選將要過期的數據淘汰
volatile-random
從已設置過期時間的數據集中任意選擇數據淘汰
allkeys-lru
從所有數據集中挑選最近最少使用的數據淘汰;最常用的熱點數據緩存策略
allkeys-random
從所有數據集中任意選擇數據進行淘汰
no-envicition
禁止驅逐數據
緩存熱點數據,啟用 allkeys-lru 淘汰策略,--------------------- 作者:zzpueye 來源:CSDN 原文:https://blog.csdn.net/zzpueye/article/details/81451916 版權聲明:本文為博主原創文章,轉載請附上博文鏈接!