liveBook · Manning

LRU

As explained in Fast by Default

An LRU cache stores reusable entries and evicts the entries that have gone unused for the longest time when capacity is exceeded.

An LRU cache bounds memory used by reusable data. Give it a maximum entry count, then evict entries by last access time when capacity is reached, preserving recently used entries while preventing unbounded growth. section 5.2.3

Use LRU eviction for state that improves responsiveness but need not remain resident forever, such as document caches. It is one safeguard within a broader memory strategy that also limits undo stacks and monitors consumption over extended use. section 5.2.3

Apply LRU caching as an operational memory control:

  • Set an explicit maximum entry count rather than allowing cached data to grow indefinitely. section 5.2.3
  • Evict cached documents according to last access time when the bound is exceeded. section 5.2.3
  • Track memory consumption over time and test day-long usage patterns for growth that suggests leaks. section 5.2.3

How Fast by Default covers it

How deep it goes
Specifies entry-count bounds and last-access eviction, while deferring cache data-structure implementation details.
Examples
Uses document caches alongside size-limited undo stacks in desktop technical applications.
What you can do after
Operate/configure bounded caches and validate their memory behavior through extended-session performance testing.
How it connects
Connects LRU caches with memory monitoring, undo stacks, document caches, and memory-leak detection.

Also explained in

Compare how 5 books explain LRU →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fast by Default. The section links point to the parts of the book it draws on.