DEV Community

Chandraprakash Soni
Chandraprakash Soni

Posted on • Originally published at Medium

 

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:

Top comments (0)

This post blew up on DEV in 2020:

js visualized

🚀⚙️ JavaScript Visualized: the JavaScript Engine

As JavaScript devs, we usually don't have to deal with compilers ourselves. However, it's definitely good to know the basics of the JavaScript engine and see how it handles our human-friendly JS code, and turns it into something machines understand! 🥳

Happy coding!