In this write strategy, data is first written to the cache and then to the database. The cache sits in-line with the database and writes always go through the cache to the main database. This helps cache maintain consistency with the main database.
write-through
Here’s what happens when an application wants to write data or update a value:
The application writes the data directly to the cache.
The cache updates the data in the main database. When the write is complete, both the cache and the database have the same value and the cache always remains consistent.
Read-through cache sits in-line with the database. When there is a cache miss, it loads missing data from database, populates the cache and returns it to the application.
read-through
Both cache-aside and read-through strategies load data lazily, that is, only when it is first read.