佳木斯湛栽影视文化发展公司

主頁(yè) > 知識(shí)庫(kù) > Redis的LRU機(jī)制介紹

Redis的LRU機(jī)制介紹

熱門(mén)標(biāo)簽:呼叫中心市場(chǎng)需求 鐵路電話系統(tǒng) Linux服務(wù)器 AI電銷(xiāo) 百度競(jìng)價(jià)排名 網(wǎng)站排名優(yōu)化 地方門(mén)戶網(wǎng)站 服務(wù)外包

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

原文中寫(xiě)得很清楚:

復(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í)間但還沒(méi)有過(guò)期的key,而對(duì)于沒(méi)有設(shè)置過(guò)期時(shí)間的key,Redis是永遠(yuǎn)保留的。當(dāng)然,如果你不想刪除沒(méi)有過(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

您可能感興趣的文章:
  • 如何高效使用Redis作為L(zhǎng)RU緩存
  • Redis中LRU淘汰策略的深入分析
  • Redis緩存常用4種策略原理詳解
  • 手動(dòng)實(shí)現(xiàn)Redis的LRU緩存機(jī)制示例詳解

標(biāo)簽:黃山 湖南 湘潭 蘭州 銅川 衡水 崇左 仙桃

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Redis的LRU機(jī)制介紹》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    保靖县| 石棉县| 鹿邑县| 项城市| 南陵县| 鲁甸县| 南溪县| 方山县| 巴东县| 泽普县| 扎兰屯市| 林甸县| 渝中区| 和平县| 浠水县| 准格尔旗| 扬州市| 上饶县| 太和县| 平南县| 花莲市| 那曲县| 灵川县| 乐清市| 灵山县| 锦州市| 滕州市| 芷江| 广丰县| 石城县| 芦山县| 宁晋县| 亳州市| 怀集县| 资阳市| 治多县| 玉龙| 东兰县| 孝昌县| 来安县| 曲水县|