DEV Community

Chandraprakash Soni
Chandraprakash Soni

Posted on • Originally published at Medium

3 1

Getting Started with Caching (Redis + NodeJS)

This post is a basic introduction to caching and how it works. We will be using Redis for caching with Nodejs to show you how we can take advantage of caching to improve the speed and performance of the application and to reduce the overhead from server resources.

NodeJS + Caching

What is Caching ?
Caching (pronounced “cashing”) is the process of storing data in a cache. A cache is a temporary storage area. A cache as a data store is easier for the client (or server) to reach, as opposed to a permanent data store that might be located on a different service, which takes more time and resources to reach (a database or an external API endpoint).

For example: The files you automatically request by looking at a Web page are stored on your hard disk in a cache subdirectory under the directory for your browser.

Now let’s take a look on Redis. (Source: Redis Official)

What is Redis ?
Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes with radius queries and streams. Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster.

Let’s build very basic project to implement caching using redis:

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

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

Okay