DEV Community

Ashis Chakraborty
Ashis Chakraborty

Posted on • Originally published at towardsdatascience.com on

System Design Basics: Getting started with Caching

Caching is an essential topic of system design. It is one of the essential techniques of system design. In almost all the systems, we might need to use caching. It is a technique used for the performance improvement of a system.

What is Cache?

The cache is a piece of hardware or software that stores data that can be retrieved faster than other data sources. Caches are generally used to keep track of frequent responses to user requests.

We need to increase the number of cache hits and decrease the cache miss rate for performance improvement.

Cache Invalidation:

In the case of data modification in DB, if the cache contains the previous data, then that is called stale data. So, we need to have a technique for invalidation of cache data. Else, the application will show inconsistent behavior. As cache has limited memory, we need to update data stored in it. This process is known as Cache Invalidation. Some techniques for cache invalidation are Write-through Cache, Write-back Cache, Cache-Aside, Read-Through Cache, etc.

Cache Eviction policy:

A cache is a backup of primary data storage; It has a limited amount of space. We may need to remove them from the cache. These are called eviction policies. Some well-known policies are First In First Out, Last In First Out, Least Recently Used(LRU), Least Frequently Used (LFU), etc. According to the requirements, we have to select an eviction policy for the system.

Continue reading on Towards Data Science ยป
If you don't have a medium account check this link

Top comments (0)