liveBook · Manning

Cache key

As explained in Latency

A cache key is an identifier derived from a request or function input that selects a corresponding cached result.

A cache key is an identifier that selects the cached value associated with a request or function input. A hit returns that value; a missing or expired key produces a miss requiring retrieval from the backing store. section 6.2 section 6.3.1

In a cache-aside workflow:

  • The application looks up the cache using the key. section 6.3.1
  • A hit returns the associated value directly. section 6.3.1
  • A miss causes the application to query the backing store, transform the result, and store it under the same key. section 6.3.1

User information keyed by user ID

An application uses a user ID as the cache key, queries the database when the key is absent, converts the returned user information to JSON, and stores that JSON under the ID. 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 cache-aside sequence shows the key lookup, database fallback, and cache update after a miss. section 6.3.1

How Latency covers it

How deep it goes
Explains hits, misses, expiration, cache updates, and hit-to-miss measurement through a cache-aside workflow.
Examples
Uses user IDs as keys for JSON-encoded user information and illustrates database fallback after a miss.
What it assumes
Assumes an application, cache, and backing store, while defining cache hits, misses, and key-based lookup directly.
What you can do after
Apply cache-aside caching by choosing a lookup key, handling misses, querying the backing store, and updating the cache.
How it connects
Connects cache hits, cache misses, cache-aside caching, backing stores, negative caching, and cache replacement policies.

Also explained in

Compare how 3 books explain cache key →

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.