API Reference

Node-redis

Modern Redis client for Node.js with promises, pipelining, clustering, and Lua scripting.

Official Documentation ↗
CompatibilityThis documentation covers version v4.7. Check the official docs for the latest API surface.

Installation

npmnpm install redis
pnpmpnpm add redis
yarnyarn add redis

Methods

node-redis is the modern Redis client for Node.js. It provides a promise-based API, connection pooling, pipelining, transactions, pub/sub, Lua scripting, and cluster support.

Key Features

  • Promises: Async/await API by default
  • Pipelining & transactions: Batch commands for speed and atomicity
  • Cluster support: Automatic sharding and redirection
  • Pub/sub: Channel-based messaging
  • Lua scripting: EVAL and EVALSHA with friendly helpers

Errors

The following points are quoted verbatim from the official documentation (https://github.com/redis/node-redis). Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.

  • “error” client will emit error when encountering an error connecting to the Redis server or when any other in Node Redis occurs. (https://github.com/redis/node-redis)
  • If you use a command without callback and encounter a ReplyError it is going to be emitted to the error listener. (https://github.com/redis/node-redis)
  • Setting enable_offline_queue to false will disable this feature and the callback will be executed immediately with an error, or an error will be emitted if no callback is specified. (https://github.com/redis/node-redis)

Security notes

Quoted from the official documentation (https://github.com/redis/node-redis); this is not a complete threat model.

FAQ

What is the difference between multi and pipeline?
multi runs commands as a single atomic transaction using MULTI/EXEC, guaranteeing they execute together. pipeline batches commands to reduce round trips without atomicity, which is faster when transactions are not needed.
How do I handle connections dropping?
Configure socket.reconnectStrategy to control retry timing. The client auto-reconnects and re-sends buffered commands. Subscribe to client.on('error') to log issues and avoid unhandled rejections.
Does node-redis support clustering?
Yes. Use createCluster with nodes and options to connect to a Redis Cluster. The client routes commands to the correct shard and handles MOVED and ASK redirections automatically.