Esta página se muestra en inglés. Una traducción al español está en curso.
ConfigsJul 16, 2026·3 min de lectura

node-redis — Official Redis Client for Node.js

High-performance Redis client for Node.js with TypeScript support, auto-pipelining, Lua scripting, and cluster/sentinel support.

Listo para agents

Staging seguro para este activo

Este activo primero queda en staging. El prompt copiado pide inspeccionar los archivos staged antes de activar scripts, config MCP o config global.

Stage only · 29/100Política: staging
Superficie agent
Cualquier agent MCP/CLI
Tipo
CLI Tool
Instalación
Single
Confianza
Confianza: Established
Entrada
node-redis Overview
Comando de staging seguro
npx -y tokrepo@latest install d7dc01bf-8135-11f1-9bc6-00163e2b0d79 --target codex

Primero deja archivos en staging; la activación requiere revisar el README y el plan staged.

Introduction

node-redis is the official Redis client for Node.js, maintained by Redis Ltd. Version 4+ provides a modern async/await API with full TypeScript type definitions, automatic command pipelining, and support for Redis modules like RediSearch, RedisJSON, and RedisTimeSeries. It connects to standalone Redis, Sentinel, and Cluster deployments.

What node-redis Does

  • Connects to Redis standalone, Sentinel, and Cluster topologies
  • Executes all Redis commands via a fully typed async API
  • Pipelines commands automatically to reduce round-trip latency
  • Supports Pub/Sub, streams, transactions, and Lua scripting
  • Integrates with Redis modules for JSON, search, time-series, and graph operations

Architecture Overview

node-redis uses a single TCP connection per client (or a pool in cluster mode) and communicates via the RESP protocol. Commands are queued and flushed in batches using automatic pipelining, which groups multiple commands into a single network write. The client handles reconnection with configurable backoff, and in cluster mode it discovers the slot map and routes commands to the correct shard automatically.

Setup & Configuration

  • Install via npm install redis (includes TypeScript types)
  • Connect with createClient({ url: 'redis://localhost:6379' })
  • Enable auto-pipelining (on by default in v4+) for batched command execution
  • For Sentinel, use createClient({ sentinel: { ... } }) with master name and sentinels list
  • For Cluster, use createCluster({ rootNodes: [...] }) to connect to Redis Cluster

Key Features

  • Automatic pipelining batches commands for higher throughput
  • Full TypeScript type definitions for all Redis commands
  • Built-in support for Redis Cluster and Sentinel topologies
  • Pub/Sub with dedicated subscriber connections
  • Extensible module support for RediSearch, RedisJSON, and RedisTimeSeries

Comparison with Similar Tools

  • ioredis — mature community client with similar features, node-redis is the official library maintained by Redis Ltd
  • redis-py — official Python client, node-redis serves the same role for Node.js
  • Jedis — synchronous Java client, node-redis is async-first for the Node.js event loop
  • Lettuce — reactive Java client, node-redis uses async/await native to JavaScript

FAQ

Q: What changed between node-redis v3 and v4? A: v4 switched to async/await, added TypeScript types, introduced auto-pipelining, and added module support. The callback API was removed.

Q: How does auto-pipelining work? A: Commands issued in the same event loop tick are batched into a single network write, reducing round trips without requiring explicit pipeline calls.

Q: Can I use node-redis with Valkey or DragonflyDB? A: Yes. node-redis communicates via the standard RESP protocol, which Valkey and DragonflyDB implement.

Q: How do I handle connection drops? A: node-redis reconnects automatically with exponential backoff. Listen to the error and reconnecting events for visibility.

Sources

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados