Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Advantages of Client-Side Caching
3.
Implementation of Client-Side Caching
4.
Concept of Tracking
5.
Frequently Asked Questions
5.1.
Define Client-Side Caching.
5.2.
Write down the purpose of Client-Side Caching.
5.3.
Name the tern used for Client-Side Caching Support.
5.4.
Name the two methods needed for the implementation of client-side caching.
5.5.
Explain the default mode of client-side caching.
6.
Conclusion
Last Updated: Mar 27, 2024

Client-Side Caching Manual in Redis

Author Prachi Singh
0 upvote

Introduction

Client-side caching is a method used to create high-performance services. It exploits the memory available on application servers, which are usually different from the database nodes, to store some subset of the database information directly on the application side.

Typically when data is required, the application servers ask the database about such information, like in the following diagram:

When client-side caching is used, the application, in turn, stores the reply of important queries directly inside the application memory so that it can reuse such responses later, without contacting the database again.

Advantages of Client-Side Caching

The two significant advantages of client-side caching are:

  1. Availability of data with negligible latency.
  2. Receiving fewer queries along with the database, providing the dataset with the ability to serve with a smaller number of nodes.

Implementation of Client-Side Caching

The Redis client-side caching support is termed Tracking and has two modes:

  • The server examines information about what keys a given client accessed and sends invalidation messages when the duplicate keys are modified in the default mode. This costs memory on the server-side but sends invalidation messages only for the set of keys that the client might have in memory.
  • The server does not attempt to examine information about what keys a given client accessed in the broadcasting mode, so this mode costs no memory at all on the server-side. Instead, clients subscribe to key prefixes such as object: or user: and receive a notification message every time a key matching a subscribed prefix is touched.

Concept of Tracking

As users can see, clients do not need, by default, to tell the server what keys they are caching. The server tracks every key mentioned in the context of a read-only command because it could be cached.

This has the clear advantage of not requiring the client to tell the server what caching needs. Moreover, in many clients implementations, this is what you want because a good solution could be to cache everything that is not already cached, using a FIFO approach: users may want to cache an appropriate number of objects, every new data they retrieve, they could cache it, discarding the oldest cached object. More advanced implementations may instead drop the least used thing or alike.

Frequently Asked Questions

Define Client-Side Caching.

Client-side caching is a method used to create high-performance services.

Write down the purpose of Client-Side Caching.

When client-side caching is used, the application, in turn, stores the reply of important queries directly inside the application memory so that it can reuse such responses later, without contacting the database again.

Name the tern used for Client-Side Caching Support.

Tracking

Name the two methods needed for the implementation of client-side caching.

Default mode and Broadcasting Mode

Explain the default mode of client-side caching.

The server examines information about what keys a given client accessed and sends invalidation messages when the duplicate keys are modified in the default mode. 

Conclusion

So that's the end of the article Client-Side Caching.

After reading about partitioning, are you not feeling excited to read/explore more articles on Client-Side Caching in Manual Redis? Don't worry; Coding Ninjas has you covered.

However, you may want to pursue our premium courses to give your job an advantage over the competition!

With our Coding Ninjas Studio Guided Path, you may learn about Data Structures and Algorithms, Competitive Programming, JavaScript, System Design, and more! Check out the mock test series and participate in the contests on Coding Ninjas Studio if you want to put your coding talents to the test! However, if you've just started school and are looking for answers to concerns raised by digital behemoths such as Amazon, Microsoft, Uber, and others. As part of your placement preparations, you must evaluate the obstaclesinterview experiences, and interview package in this case. Please vote for our blogs if you find them valuable and exciting.

Happy studying!!

Live masterclass