liveBook · Manning

Cache hit

As explained in Latency

A cache hit occurs when requested data is found in the cache and can be returned without accessing the backing store.

A cache hit occurs when a lookup finds the requested value under its cache key. The application returns that value directly, avoiding the backing store and its slower lookup or computation. section 6.2

A cache hit is the fast path in cache-aside caching:

  • The application looks up a cache key. section 6.3.1
  • If the key exists and has not expired, the cache returns the value. section 6.3.1
  • If the key is absent or expired, the application queries the backing store, transforms the result, and updates the cache. section 6.3.1
  • Measure effectiveness with the cache hit-to-miss ratio; a low hit ratio can leave caching overhead without enough latency reduction. section 6.2

User lookup

An application uses a user ID as the cache key. On a hit, it returns the cached user information. On a miss, it reads the database, converts the result to JSON, and stores it under that user ID for later requests. section 6.3.1

Figure 6.1 With cache-aside caching, the client first looks up a key from the cache. On a cache miss, the client queries the database and updates the cache.
Figure 6.1: With cache-aside caching, client first looks up a key from the cache. On cache miss, the clients queries the database and updates the cache.

The request path makes the hit fast path and the miss path explicit: cache lookup first, followed by database retrieval and cache update only on a miss. section 6.3.1

How Latency covers it

How deep it goes
Defines hits, contrasts misses, explains hit-to-miss ratio, and traces cache-aside handling without detailing replacement-policy algorithms.
Examples
Uses user IDs, database records, JSON values, Redis, and REST API searches as concrete caching contexts.
What it assumes
Assumes cache keys, cached values, and a backing store; teaches the hit-versus-miss distinction directly.
What you can do after
Apply it via cache-aside caching by checking a key, reading a hit, or fetching and storing a miss.
How it connects
Connects cache hits to cache misses, cache-aside caching, backing stores, cache hit-to-miss ratio, and negative caching.

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 Latency. The section links point to the parts of the book it draws on.