DEV Community

Ashis Chakraborty
Ashis Chakraborty

Posted on • Originally published at towardsdatascience.com on

3 1

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

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

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

Okay