Skip to content
Ameen Abozaid
Planned lessonMID-039-L02

Read-through and write-through

  • Lesson 2 of 5
  • Mid-level
On This Lesson 4 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

know the patterns where the cache layer loads and writes data itself.

Planned topics

  • Read-through: the caller asks the cache; the cache loads from the database on a miss (Caffeine LoadingCache, Spring @Cacheable behave like this).
  • Write-through: a write goes to the cache and the database synchronously, in one operation.
  • Benefit: one code path and a cache that is always up to date after writes.
  • Failure: write-through is as slow as the slower store and needs a plan if one write fails; the two stores can diverge without a transaction.
Draft outline details

Demonstration

diagram: app → cache layer → database for both read and write; compare to cache-aside where the app talks to both.

Check your understanding

Who loads data on a miss in read-through?

Show answer

The cache layer, not the caller.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.