DEV Community

Aniketh Deshpande
Aniketh Deshpande

Posted on

1

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.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (1)

Collapse
 
rudu1 profile image
Rudram

wah subhanallah!

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay