liveBook · Manning

Write-through caching

As explained in Advanced Algorithms and Data Structures

Write-ahead caching writes data to a cache before writing it to the underlying storage system.

Write-through caching writes every changed entry to both the cache and the underlying storage at the same time. The cache stays available for fast reads, while persistent storage is updated immediately. section 7.6

Use the policy when the workload favors reliable, repeated reads over faster writes:

  • Choose it for read-intensive applications where data is written once or infrequently and then read many times. section 7.6
  • Expect slower writes than with write-behind caching, because each change reaches the main storage immediately. section 7.6
  • Reduce data-loss risk to nearly zero except for edge cases and malfunctions, while retaining caching benefits for reads. section 7.6

Session data

A session-data system can write each update to the cache and database together, then serve subsequent reads from the cache. This suits data written once or seldom and read repeatedly soon afterward. section 7.6

Unlike write-behind, which delays storage writes, write-through does not improve writing performance. Unlike write-around, it does not leave newly written data out of the cache. Read-through instead describes how entries are populated when read, not this simultaneous write policy. section 7.6

How Advanced Algorithms and Data Structures covers it

How deep it goes
Defines simultaneous cache and storage writes, then contrasts latency, data-loss risk, and alternative cache policies.
Examples
Uses session data as the representative workload: infrequent writes followed by many near-term reads.
What it assumes
Assumes familiarity with caches, main storage, database reads and writes, and cache-policy distinctions.
What you can do after
Apply it to favor near-zero data-loss risk and fast repeated reads when slower writes are acceptable.
How it connects
Contrasts with write-behind, write-around, and read-through caching while retaining caching's read-performance role.

Also explained in

Compare how 3 books explain write-through caching →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Advanced Algorithms and Data Structures. The section links point to the parts of the book it draws on.