1:1 mentoring with Big Tech AI engineers
System Design

Semantic Caching

When a cache may answer a rephrased question: the scope key that stops answers crossing users and tenants, the verifier that stops similar-but-wrong hits, freshness, and the break-even against the tier the hit replaces.

Last updated

Core10 min readFirst readYour First Agentic System

After this section you can

  • Compute the break-even hit rate and wrong-hit share for the tier a cache replaces
  • Write a scope key that includes a permission hash, and state the store rule
  • Choose a threshold and a verifier by the cost of a false hit, not the hit rate
07

Semantic Caching

A cache that answers rephrased questions: scope the key, verify the hit, price the miss.

Key idea

A semantic cache answers a new question with the stored answer to a similar one. A hit saves a model call; a wrong hit is a confident error no log records. Scope each entry, verify each hit, and price the break-even per tier.

Scope first, then the gate: a hit is served only when both pass
THE REQUEST PATH Request question + identity Never cache? PII, actions, prices Scope key tenant, permissions, KB Call the model no embed, no store Gate threshold, then 5 checks Nearest in scope embed, then top match Serve stored no model call Call the model after a miss Store with its scope and time no no yes hit miss end_turn

Amber: decisions and model calls. Teal: the scope key. Purple: memory. Pans sideways on a phone.

Related

More in System Design

Get full access to all 149 sections with code examples, diagrams, and interactive animations.

Unlock Premium