What it is
In a write through cache, every write goes to the cache and the database as part of the same operation. The cache updates its entry and synchronously forwards the write to the backing store before the operation is considered complete.
Why it helps
- The cache and database stay consistent for the written key.
- Reads right after a write are fast because the new value is already cached.
- There is no window where the cache holds stale data for that key.
Trade offs
- Every write pays the latency of both the cache and the database.
- Data that is written but never read still occupies cache space, wasting memory.
- It is often paired with read through so reads and writes share one inline path.
When to use it
Write through fits workloads where freshly written data is read again soon, such as user profiles or session state, where the extra write latency is worth the consistency.
Key idea
Write through keeps cache and database in lockstep by writing both synchronously, trading higher write latency for strong read freshness.