← All patterns The problem A popular product page repeatedly reads the same records. Database work grows even though most readers need the same data.
When it fits Repeated reads tolerate a declared freshness window and cache misses can still reach the source.
The whole architecture
Architecture diagram Download SVG Read and write paths share authoritative SQL while the application manages cached copies.
Blue arrows are application calls. Cache has no onward request path to SQL.
cache aside architecture Read and write paths share authoritative SQL while the application manages cached copies. Blue arrows are application calls. Cache has no onward request path to SQL. Application-owned cache-aside logic Data dependencies clients → read: read clients → write: write read → cache: lookup / fill read → sql: miss → source write → sql: commit first write → cache: invalidate after commit read write lookup / fill miss → source commit first invalidate after commit Clients call an application API rather than an authoritative database. Clients Read or change data On a miss, this API calls SQL separately and fills the cache. Read API Cache lookup / fill A successful source write precedes cache invalidation. Write API Commit then invalidate Copies can become stale; expiration and invalidation need an explicit freshness policy. Cache Expiring keyed copies The source of truth remains available to the application on a cache miss. Authoritative SQL Business records Cache invalidation races and miss stampedes need separate handling. Freshness policy TTL, invalidation races and cold-cache load Select a component, or focus it and press Enter, to read its role.
Cache never forwards a request to the application or SQL. A cached copy and a committed source write can differ during concurrent activity. Walk through the design
Follow one operation Core flow Failure & recovery
Select a step to highlight its participants. This conceptual walkthrough is separate from challenge scoring.
Arrows show the conceptual relationships used by this walkthrough.
1 Look up the key2 Read the source on a miss3 Populate and returnStep 1 of 3 Look up the key Client asks App for a product. App reads Cache first.
← Previous Restart Next step →
Trade-offs to make explicit Hits save source reads; misses add a cache lookup before the source lookup. Expiration and invalidation bound some stale data but do not make concurrent readers strongly consistent. Failure modes to plan for A cold cache or synchronized expiry can overwhelm the database. A reader can repopulate an old value after a writer invalidates it. Consider versioning and request coalescing. Before you build Explain your decision What freshness contract would you declare for a product price, and how would you prevent a cache-miss stampede?
Use Plan & estimate inside practice to record your assumptions and trade-offs.
These links open the original challenges. Existing round unlocks, completions and points apply.
Rescue the overloaded API Practice app/cache/SQL capacity. Invalidation races are discussed here, not scored by that workload.
Open challenge → The great ticket rush Use cache-aside for eligible reads while keeping reservation writes authoritative.
Open challenge → Further reading Microsoft · Cache-aside ↗
Original PractiseGrid explanations and conceptual diagrams, with primary references for further study. Dedicated scored exercises can be added as coverage grows.