explaingit

redis/node-redis

17,522TypeScriptAudience · developerComplexity · 2/5Setup · moderate

TLDR

The official Node.js client library for Redis, lets your server-side JavaScript or TypeScript app send commands to a Redis instance for caching, session storage, job queuing, and pub/sub messaging.

Mindmap

mindmap
  root((node-redis))
    What it does
      Talks to Redis
      From Node.js apps
    Commands
      set and get
      hSet hGetAll
      Transactions
      Pub/Sub
    Use Cases
      Caching
      Sessions
      Job queues
      Event broadcast
    Tech
      TypeScript
      Node.js
    Features
      TLS support
      Connection pooling
      Redis Stack add-ons
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Cache expensive database query results in Redis from a Node.js API to speed up repeated requests.

USE CASE 2

Store and retrieve user session data in Redis for a Node.js web application.

USE CASE 3

Implement a pub/sub event broadcast or background job queue between Node.js services using Redis.

Tech stack

TypeScriptNode.jsRedis

Getting it running

Difficulty · moderate Time to first run · 30min

Requires a running Redis instance, local via Docker or a cloud Redis URL.

In plain English

node-redis is the official Node.js client library for Redis. Redis is a fast, in-memory data store that applications use as a cache, a message queue, a session store, or a key-value database. A client library is what your app uses to talk to it, node-redis lets server-side JavaScript or TypeScript send commands to a Redis instance and get results back. The basic flow is small. You import createClient, connect it (by default to localhost on the standard Redis port, or to any URL you give it including with TLS, a username and password, or a UNIX socket), then call methods that mirror Redis's commands, set, get, hSet, hGetAll. Each Redis command is exposed in two forms: the raw uppercase name and a friendlier camelCase version. Replies come back as JavaScript values (hash reads become objects, list reads become arrays), and Buffers are supported for binary data. Transactions are done by chaining commands after multi() and calling exec(). Pub/Sub messaging, scan-iteration helpers, and connection pooling for blocking commands are also built in. If you need a command the library does not yet wrap, sendCommand lets you call it raw. You would use node-redis any time a Node.js application needs to talk to Redis, caching expensive results, storing sessions, queueing background jobs, or broadcasting events between services. The package ships as a "whole in one" install that bundles the base client plus extensions for the Redis Stack add-ons: Bloom filters, JSON documents, RediSearch full-text search, Time-Series, and Entra ID authentication. You can also install only the pieces you need. The library is written in TypeScript. The full README is longer than what was provided.

Copy-paste prompts

Prompt 1
Using node-redis, write a Node.js function that caches the result of an expensive API call in Redis for 60 seconds and returns the cached value on subsequent calls.
Prompt 2
Show me how to use node-redis to implement a pub/sub system where one process publishes events and another process subscribes and logs them.
Prompt 3
Write a Node.js user session store with node-redis that saves login state using hSet and retrieves it with hGetAll, with a 30-minute expiry.
Prompt 4
I need to run several Redis commands atomically with node-redis. Show me how to use multi() and exec() in TypeScript with error handling.
Open on GitHub → Explain another repo

← redis on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.