国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 數(shù)據(jù)庫(kù) > Redis > 正文

Redis的LRU機(jī)制介紹

2020-03-17 12:42:27
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
這篇文章主要介紹了Redis的LRU機(jī)制介紹,Redis會(huì)按LRU算法刪除設(shè)置了過(guò)期時(shí)間但還沒有過(guò)期的key,而對(duì)于沒有設(shè)置過(guò)期時(shí)間的key,Redis是永遠(yuǎn)保留的,需要的朋友可以參考下
 

在Redis中,如果設(shè)置的maxmemory,那就要配置key的回收機(jī)制參數(shù)maxmemory-policy,默認(rèn)volatile-lru,參閱Redis作者的原博客:antirez weblog >> Redis as an LRU cache

原文中寫得很清楚:

復(fù)制代碼代碼如下:

Another way to use Redis as a cache is the maxmemory directive, a feature that allows specifying a maximum amount of memory to use. When new data is added to the server, and the memory limit was already reached, the server will remove some old data deleting a volatile key, that is, a key with an EXPIRE (a timeout) set, even if the key is still far from expiring automatically.

在Redis服務(wù)器占用內(nèi)存達(dá)到maxmemory的情況下,當(dāng)再想增加內(nèi)存占用時(shí),會(huì)按maxmemory-policy機(jī)制將老的數(shù)據(jù)刪除。這里簡(jiǎn)單說(shuō)一下volatile-lru,Redis會(huì)按LRU算法刪除設(shè)置了過(guò)期時(shí)間但還沒有過(guò)期的key,而對(duì)于沒有設(shè)置過(guò)期時(shí)間的key,Redis是永遠(yuǎn)保留的。當(dāng)然,如果你不想刪除沒有過(guò)期的key,那可以使用noeviction機(jī)制
復(fù)制代碼代碼如下:

# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached? You can select among five behavior:
#
# volatile-lru -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key accordingly 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

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 额敏县| 特克斯县| 洛川县| 沿河| 双峰县| 保定市| 随州市| 武夷山市| 孙吴县| 行唐县| 宾川县| 千阳县| 久治县| 祁连县| 武川县| 西丰县| 大同县| 栖霞市| 卫辉市| 新竹县| 勐海县| 邵阳县| 汉阴县| 宜阳县| 汉沽区| 中江县| 崇明县| 新和县| 胶州市| 温宿县| 望谟县| 青龙| 章丘市| 大足县| 永济市| 调兵山市| 麟游县| 乐安县| 平顺县| 南陵县| 旌德县|