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

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

深入解析Redis的LRU機制

2020-02-17 14:55:32
字體:
供稿:網(wǎng)友

這篇文章主要將給各位深入解析Redis的LRU機制,Redis會按LRU算法刪除設置了過期時間但還沒有過期的key,而對于沒有設置過期時間的key,Redis是永遠保留的,需要的朋友可以參考下吧。

在Redis中,如果設置的maxmemory,那就要配置key的回收機制參數(shù)maxmemory-policy,默認volatile-lru

原文中寫得很清楚:


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的內(nèi)容請繼續(xù)關注武林技術頻道。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 泗洪县| 海林市| 抚州市| 土默特右旗| 祁连县| 瓮安县| 永靖县| 朔州市| 郴州市| 凌云县| 博爱县| 永兴县| 阳信县| 富裕县| 云林县| 凭祥市| 淳化县| 禹城市| 江城| 普兰县| 扶绥县| 博客| 吴川市| 毕节市| 阜康市| 瓦房店市| 荔浦县| 德钦县| 通化县| 新民市| 汝阳县| 濉溪县| 南康市| 双鸭山市| 张家口市| 江孜县| 英德市| 贵溪市| 沂源县| 平南县| 许昌县|