1---2name: ioredis3description: ioredis v5 reference for Node.js Redis client — connection setup, RedisOptions, pipelines, transactions, Pub/Sub, Lua scripting, Cluster, and Sentinel. Use when: (1) creating or configuring Redis connections (standalone, cluster, sentinel), (2) writing Redis commands with ioredis (get/set, pipelines, multi/exec), (3) setting up Pub/Sub or Streams, (4) configuring retryStrategy, TLS, or auto-pipelining, (5) working with Redis Cluster options (scaleReads, NAT mapping), or (6) debugging ioredis connection issues. Important: use named import `import { Redis } from 'ioredis'` for correct TypeScript types with NodeNext.4---56# ioredis v5 — Node.js Redis Client78ioredis v5.x. Requires Node.js >= 12, Redis >= 2.6.12. 100% TypeScript.910<quick_reference>1112## Critical: Import Style1314```ts15// CORRECT — named import (required for NodeNext / moduleResolution: "nodenext")16import { Redis } from "ioredis";1718// For Cluster:19import { Redis, Cluster } from "ioredis";20```2122## Quick Reference2324| Operation | Code |25| -------------- | -------------------------------------------------------------------------- |26| Connect | `new Redis()` or `new Redis(6379, "host")` or `new Redis("redis://...")` |27| Get/Set | `await redis.set("key", "val")` / `await redis.get("key")` |28| Pipeline | `await redis.pipeline().set("a","1").get("a").exec()` |29| Transaction | `await redis.multi().set("a","1").get("a").exec()` |30| Pub/Sub | `sub.subscribe("ch")` / `sub.on("message", cb)` / `pub.publish("ch", msg)` |31| Lua script | `redis.defineCommand("name", { numberOfKeys: 1, lua: "..." })` |32| Scan | `redis.scanStream({ match: "prefix:*", count: 100 })` |33| Graceful close | `await redis.quit()` |34| Force close | `redis.disconnect()` |3536</quick_reference>3738<gotchas>3940## Common Gotchas41421. **Named import**: Always `import { Redis } from "ioredis"` with NodeNext resolution432. **Pub/Sub isolation**: A subscribed client cannot run other commands — use separate instances443. **`maxRetriesPerRequest`**: Default is 20. Set to `null` for infinite retries (required by BullMQ)454. **Pipeline errors**: `pipeline.exec()` never rejects — errors are in each result's `[0]` position465. **`showFriendlyErrorStack`**: Performance cost — never enable in production476. **Cluster pipelines**: All keys in a pipeline must hash to slots served by the same node487. **`enableAutoPipelining`**: 35-50% throughput improvement, safe to enable globally4950</gotchas>5152<references>5354## When to Load References5556| Need | Reference file |57| ------------------------------------------------------------------------------ | -------------------------------------------------------------------- |58| Connection setup, RedisOptions, TLS, retryStrategy, lifecycle | [references/connection-options.md](references/connection-options.md) |59| Core API: pipelines, transactions, Pub/Sub, Lua scripting, scanning, events | [references/core-api.md](references/core-api.md) |60| Streams, auto-pipelining, transformers, binary data, error handling, debugging | [references/advanced-patterns.md](references/advanced-patterns.md) |61| Redis Cluster setup, ClusterOptions, Sentinel config, failover | [references/cluster-sentinel.md](references/cluster-sentinel.md) |6263</references>