DEV Community

Aniketh Deshpande
Aniketh Deshpande

Posted on

Write Through

Write through cache is a simple to implement caching mechanism.

  • Here the newly arrived data is written into cache and as well as persisted into the disk or a database. Atomicity is maintained.

There are two ways to implement it:
1] The application writes data to cache and database simultaneously

Write through cache

2] The application writes data to cache and then the cache writes the data into the database.

Write through cache 2

Advantages:
  • Simple to implement.
  • Faster response times.
  • Data integrity because of atomic nature of write operation.
  • Lower latency for subsequent reads.
Disadvantages:
  • Cache pollution: Since every time the data is filled into cache, it can get filled with less frequently read data and more cache eviction which could introduce some latency.

  • Not suitable for write intensive scenarios as the write operations are slower compared to other methods because data needs to be written in cache as well as persistent storage everytime.

Top comments (1)

Collapse
 
rudu1 profile image
Rudram

wah subhanallah!