LRU
LRU is a cache replacement policy that evicts the item whose most recent access occurred furthest in the past.
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.
- How it is used
- Bounds reusable application state to prevent unbounded memory growth in long-running desktop tools.
- 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.
Advanced Algorithms and Data Structures
An LRU cache is a cache that evicts the entry that has been unused for the longest time when it reaches capacity.
- How it is used
- Uses caching to avoid repeated computation while retaining fast lookup, insertion, retrieval, sizing, and eviction.
- How deep it goes
- Develops the hash-table and doubly-linked-list design through pseudocode, synchronized updates, and amortized constant-time analysis.
- Examples
- Uses company-name entries, an Acme cache miss, an EvilCorp update, and diagrams or pseudocode for insertion and eviction.
- What you can do after
- Build it from scratch with a capacity, hash table, doubly linked list, head, tail, insertion, lookup, update, and eviction operations.
Read how Advanced Algorithms and Data Structures explains LRU →
Acing the Frontend Interview
Least recently used eviction removes the cache item with the oldest recorded access when space is needed.
- How it is used
- Evaluates caching knowledge and efficient in-memory implementation in an interview-style system-design discussion.
- How deep it goes
- Explains eviction behavior, recency tracking, constant-time operations, and a complete TypeScript implementation.
- Examples
- Uses a TypeScript LRUCache, a React demo, and stale-entry eviction such as 1 → 1.
- What you can do after
- Build it from scratch with TypeScript Map operations that provide constant-time access, insertion, recency updates, and eviction.
Designing Deep Learning Systems: A guide for software engineers
The least recently used algorithm evicts the item that has gone unused for the longest time when a cache reaches its capacity.
- How it is used
- Manages model swapping in multitenant prediction services when memory or GPU capacity cannot hold every required model.
- How deep it goes
- Defines the eviction role and pairs it with model partitioning, but defers detailed cache implementation to a prediction-service example.
- Examples
- Uses a multitenant prediction service and an intent-classification service to illustrate model caching and swapping.
- What you can do after
- Operate model caches that evict inactive models and free capacity for incoming prediction requests.
Read how Designing Deep Learning Systems: A guide for software engineers explains LRU →
Software Engineering for Data Scientists
An LRU cache is a cache that evicts the least recently used entries when its capacity is reached.
- How it is used
- Speeds repeated supervised machine-learning prediction calls in interactive applications.
- How deep it goes
- Defines recency-based eviction and demonstrates decorator-based caching, but stops short of implementing the mechanism internally.
- Examples
- Uses repeated random-forest predictions, runtime comparisons, a bounded cache, and an implementation exercise.
- What you can do after
- Apply it via Python’s functools.lru_cache to accelerate repeated model calls and limit cache growth.
Read how Software Engineering for Data Scientists explains LRU →
Also covered in
- Latency
- Designing AI SystemsIn early access (MEAP)
What to know first
- cachingCaching is the temporary storage of data or computed results for reuse, reducing the work or delay of retrieving or computing them again.
- listA list is an ordered collection of elements arranged in a sequence.
- arrayAn array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
Related concepts
- cachingkind of · Caching is the temporary storage of data or computed results for reuse, reducing the work or delay of retrieving or computing them again.
- least frequently usedcontrasts with · Least frequently used is a cache-eviction policy that removes the entry with the lowest access frequency when capacity is exhausted.
- Mapuses · A map is an associative data structure that stores key-value associations and supports retrieving values by key.
- cache replacement policykind of · A cache replacement policy is a rule or algorithm for selecting which cached item to remove when capacity is insufficient or cached data must be discarded.
- Redisuses · Redis is an in-memory data-structure store that provides network-accessible data storage and operations and can serve as a database, cache, or message broker.
- amortized analysismeasures · Amortized analysis bounds the total cost of a sequence of operations by distributing occasional expensive operations across the sequence.
Questions about LRU
What is LRU?
LRU is a cache replacement policy that evicts the item whose most recent access occurred furthest in the past.
Which Manning books explain LRU?
Fast by Default, Advanced Algorithms and Data Structures, Acing the Frontend Interview, Designing Deep Learning Systems: A guide for software engineers and Software Engineering for Data Scientists.
What should I know before learning LRU?
Manning books that teach LRU usually introduce caching, list and array first.
What is the difference between LRU and least frequently used?
LRU is a cache replacement policy that evicts the item whose most recent access occurred furthest in the past. Least frequently used is a cache-eviction policy that removes the entry with the lowest access frequency when capacity is exhausted.
What is LRU a kind of?
LRU is a kind of caching. Caching is the temporary storage of data or computed results for reuse, reducing the work or delay of retrieving or computing them again.
What is LRU also called?
LRU is also called least recently used.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.




