What is Caching
Imagine a library where books are stored on shelves. Retrieving a book from a shelf takes time, so a librarian decides to keep a small table near the entrance. This table is like a cache, where the librarian places the most popular or recently borrowed books.
Now, when someone asks for a frequently requested book, the librarian checks the table first. If the book is there, it’s quickly provided. This saves time compared to going to the shelves each time. The table acts as a cache, making popular books easily accessible.
- The same things happen in the system. In a system accessing data from primary memory (RAM) is faster than accessing data from secondary memory (disk).
- Caching acts as the local store for the data and retrieving the data from this local or temporary storage is easier and faster than retrieving it from the database.
- Consider it as a short-term memory that has limited space but is faster and contains the most recently accessed items.
- So If you need to rely on a certain piece of data often then cache the data and retrieve it faster from the memory rather than the disk.
As you know there are many benefits of the cache but that doesn’t mean we will store all the information in your cache memory for faster access, we can’t do this for multiple reasons, such as:
- Hardware of the cache which is much more expensive than a normal database.
- Also, the search time will increase if you store tons of data in your cache.
- So in short a cache needs to have the most relevant information according to the request which is going to come in the future.
Caching – System Design Concept
Caching is a system design concept that involves storing frequently accessed data in a location that is easily and quickly accessible. The purpose of caching is to improve the performance and efficiency of a system by reducing the amount of time it takes to access frequently accessed data.
Important Topics for Caching in System Design
- What is Caching
- How Does Cache Work?
- Where Cache can be added?
- key points to understand Caching
- Types of Cache
- Applications of Caching
- What are the Advantages of using Caching?
- What are the Disadvantages of using Caching?
- Cache Invalidation Strategies
- Eviction Policies of Caching
Contact Us