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.

Top comments (0)