liveBook · Manning

Cache hit

As explained in Advanced Algorithms and Data Structures

A cache hit occurs when a requested data item is present in the cache and can be accessed there.

A cache hit occurs when a requested item is already stored in the cache. In an LRU cache, updating that item moves its list node to the front so its recent use is preserved. section 7.4.2

An LRU cache handles a hit by:

  • Looking up the key in a hash table and retrieving its linked-list node. section 7.4.2

Updating an existing entry

Looking up “EvilCorp” produces a cache hit. Its stored data is updated, the node is detached from the list, and the node is placed at the front.

How Advanced Algorithms and Data Structures covers it

How deep it goes
Explains lookup, node movement, pointer preservation, and constant-time list operations, while deferring hash computation costs.
Examples
Uses the EvilCorp update and diagrams of hash-table lookup, list movement, and node relinking.
What it assumes
Assumes hash tables and linked lists, while making node retrieval and constant-time removal explicit.
What you can do after
Build it from scratch by combining hash-table lookup with doubly-linked-list reordering.
How it connects
Connects cache hits with LRU caches, hash tables, doubly-linked lists, cache misses, and eviction.

Also explained in

Compare how 3 books explain cache hit →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Advanced Algorithms and Data Structures. The section links point to the parts of the book it draws on.