Pattern 08 / CACHE

Write-Through

Use this when keeping cache and storage fresh immediately after writes.

Pressure
Keeping cache and storage fresh immediately after writes
Mechanism
Write to cache and database in the same write path so later reads hit updated cache data
Toll
Writes are slower and unused values may occupy cache
Architecture plate08
Diagram for Write-Through
Executive brief

Write-Through fits when keeping cache and storage fresh immediately after writes. Mechanism: write to cache and database in the same write path so later reads hit updated cache data. Use it for profile updates, settings, permissions, and read-after-write sensitive screens. The toll: writes are slower and unused values may occupy cache.

Use when

Profile updates, settings, permissions, and read-after-write sensitive screens.

Example

Saving account preferences to both redis and postgresql.

Review framing

Describe the pressure first, then the mechanism, then the cost. That keeps the design grounded.

Same pressure family

Caching Patterns

07Cache-Aside (Lazy Loading)09Write-Behind (Write-Back)10Read-Through11Cache Stampede Prevention
โ† 0709 โ†’