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

Similar Reads

1. What is Caching

...

2. How Does Cache Work?

...

3. Where Cache Can be Added?

Caching is used in almost every layer of computing....

4. Key points to understand Caching

Caching can be used in a variety of different systems, including web applications, databases, and operating systems. In each case, caching works by storing data that is frequently accessed in a location that is closer to the user or application. This can include storing data in memory or on a local hard drive....

5. Types of Cache

In common there are four types of Cache…...

6. Applications of Caching

Facebook, Instagram, Amazon, Flipkart….these applications are the favorite applications for a lot of people and most probably these are the most frequently visited websites on your list....

7. What are the Advantages of using Caching?

Caching optimizes resource usage, reduces server loads, and enhances overall scalability, making it a valuable tool in software development....

8. What are the Disadvantages of using Caching?

Despite its advantages, caching comes with drawbacks also and some of them are:...

9. Cache Invalidation Strategies

Cache invalidation is crucial in systems that use caching to enhance performance. When data is cached, it’s stored temporarily for quicker access. However, if the original data changes, the cached version becomes outdated. Cache invalidation mechanisms ensure that outdated entries are refreshed or removed, guaranteeing that users receive up-to-date information....

10. Eviction Policies of Caching

Eviction policies are crucial in caching systems to manage limited cache space efficiently. When the cache is full and a new item needs to be stored, an eviction policy determines which existing item to remove....

11. Conclusion

Caching is becoming more common nowadays because it helps make things faster and saves resources. The internet is witnessing an exponential growth in content, including web pages, images, videos, and more. Caching helps reduce the load on servers by storing frequently accessed content closer to the users, leading to faster load times. Real-time applications, such as online gaming, video streaming, and collaborative tools, demand low-latency interactions. Caching helps in delivering content quickly by storing and serving frequently accessed data without the need to fetch it from the original source every time....