DEV Community

Cover image for Cache Aside
Aniketh Deshpande
Aniketh Deshpande

Posted on

Cache Aside

Cache Aside or Lazy Loading is one of the cache write policies or strategies.

  • In cache aside method, the application is responsible for storing data into cache.
  • When the client sends request to the application, it looks for data in the cache.
  • If the data is found in the cache it is called as cache-hit. The data is fetched from cache and returned to client.
  • However, if the data is not found in the cache, also called as cache-miss, the application queries for data in the database, writes the data into cache and sends the response to the client.
  • Since we store data in cache only when it is necessary, this strategy is also called as Lazy-Loading.

Cache Aside - Write Strategy

Advantages:
  • The implementation is simple.
Disadvantages:
  • The response time can be slow when there is cache miss, because, it involves many io operations to fetch data from DB and store it in cache.

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

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

Okay