← 返回起始笔记位置

知识卡片

结构图卡 · 4545.c.10

最近最少使用缓存限制容量

理解等级:中级

LRU用映射定位节点,用双向链表维护最近使用次序。读写某键时更新其位置,超过容量时淘汰最久未使用者。这样限制内存增长,但需同步映射与链表;命中也可能修改次序,不是纯只读访问。特定库的吞吐与API属于版本条件,不能把历史数字当作普遍上限。

结构图:

flowchart TD
 A[读取或写入键] --> B[映射定位节点]
 B --> C[移到最近使用端]
 C --> D{是否超过容量}
 D -->|是| E[淘汰最旧节点]
 D -->|否| F[保留当前集合]
这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Scalability · 查看原书依据

      an LRU cache contains a doubly-linked list (which actually contains the values), and a map that associates each key to a node in the linked list. Whenever a key is read or written, the appropriate node is moved to the bottom of the list, such that the least recently used node is always at the

    参考来源

    - 位置:《Cloud Native Go》第07章《Scalability》(来源项目book-sources;源文件:extracted/Cloud Native Go (Matthew A. Titmus)/_epub-src/OEBPS/ch07.xhtml) - 结论依据:LRU用映射定位节点,用双向链表维护最近使用次序。原文相应定义、示例或限制为此结论提供依据;补充纠错与版本边界在正文就近标明。 - 原始内容:an LRU cache contains a doubly-linked list (which actually contains the values), and a map that associates each key to a node in the linked list. Whenever a key is read or written, the appropriate node is moved to the bottom of the list, such that the least recently used node is always at the