DEV Community

loading...

Getting Started with Caching (Redis + NodeJS)

Chandraprakash Soni
Full-stack developer experienced in developing robust and unit tested web applications using cutting edge technology.
Originally published at Medium ・1 min read

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:

Discussion (0)