Consistency between Cache and Database, Part 2

Chunting Wu
Starbugs Weekly 星巴哥技術專欄
6 min readJul 11, 2022

--

Photo by Jesse Collins on Unsplash

This is the last article in the series. In the previous article we introduced why caching is needed and also introduced the Read Aside process and potential problems, and of course explained how to improve the consistency of Read Aside. Nevertheless, Read Aside is not enough for high consistency requirements.

One of the reasons why Read Aside can cause problems is because all users have access to the cache and database. When users manipulate data at the same time, inconsistencies occur due to various combinations of operation order.

Then we can effectively avoid inconsistency by limiting the behavior of manipulating data, which is the core concept of the next few methods.

Read Through

Read Path

  • Reading data from cache
  • If the cache data does not exist
  • Read from database by cache
  • Cache returns to the application client

Write Path

  • Don’t care, usually used in combination with Write Through or Write Ahead.

Potential Problems

--

--

Chunting Wu
Starbugs Weekly 星巴哥技術專欄

Architect at SHOPLINE. Experienced in system design, backend development, and data engineering.