濮阳杆衣贸易有限公司

主頁 > 知識庫 > Redis的LRU機制介紹

Redis的LRU機制介紹

熱門標簽:天音通信電話機器人 高德地圖標注商家在哪 機器人電話機創(chuàng)意繪畫 江西南昌百應電話機器人 隨州營銷電話機器人怎么樣 400電話申請怎么看 400電話從哪里申請濱州 杭州400電話如何申請的 hbuilder地圖標注

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

原文中寫得很清楚:

復制代碼 代碼如下:

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服務器占用內(nèi)存達到maxmemory的情況下,當再想增加內(nèi)存占用時,會按maxmemory-policy機制將老的數(shù)據(jù)刪除。這里簡單說一下volatile-lru,Redis會按LRU算法刪除設置了過期時間但還沒有過期的key,而對于沒有設置過期時間的key,Redis是永遠保留的。當然,如果你不想刪除沒有過期的key,那可以使用noeviction機制
復制代碼 代碼如下:

# 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作為LRU緩存
  • Redis中LRU淘汰策略的深入分析
  • Redis緩存常用4種策略原理詳解
  • 手動實現(xiàn)Redis的LRU緩存機制示例詳解

標簽:昆明 鶴崗 葫蘆島 石嘴山 保定 沈陽 招商 常德

巨人網(wǎng)絡通訊聲明:本文標題《Redis的LRU機制介紹》,本文關鍵詞  Redis,的,LRU,機制,介紹,Redis,;如發(fā)現(xiàn)本文內(nèi)容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Redis的LRU機制介紹》相關的同類信息!
  • 本頁收集關于Redis的LRU機制介紹的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    吴忠市| 台东县| 大新县| 仁化县| 监利县| 驻马店市| 晋江市| 克拉玛依市| 绥化市| 苗栗市| 霸州市| 芮城县| 闵行区| 岳普湖县| 即墨市| 陆丰市| 临西县| 高邑县| 武汉市| 靖远县| 西华县| 德钦县| 萝北县| 四川省| 黎城县| 杂多县| 白朗县| 巫山县| 保定市| 东台市| 翁源县| 威信县| 临沧市| 新兴县| 甘泉县| 洛扎县| 安溪县| 齐齐哈尔市| 杭州市| 桦川县| 淳安县|