API Reference

ioredis

Feature-rich Redis client for Node.js with clustering, pipelining, pub/sub, Lua scripts, and automatic reconnection for caches and queues.

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

Installation

npmnpm install ioredis
pnpmpnpm add ioredis
yarnyarn add ioredis

Methods

ioredis is a Redis client with clustering, pipelining, pub/sub, and Lua support. It is a transport and command API, not a cache policy. TTLs, eviction, key naming, and failure behavior remain application decisions.

Connections and errors

Attach an error listener. ioredis emits connection errors that can otherwise surface as unhandled events. Configure connect and command timeouts so a Redis outage does not hang every request. Use a dedicated duplicated connection for subscriptions and blocking commands.

Keys and memory

Use explicit key prefixes and TTLs. A cache with no TTL depends entirely on invalidation; one missed delete can serve stale data indefinitely. Monitor memory, evictions, and slow commands. For rate limiting, use atomic commands or Lua rather than a read-modify-write sequence.

Errors

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

FAQ

Should I use one Redis client for the whole process?
A shared client is fine for ordinary commands, but subscriptions and blocking commands need dedicated connections. Use duplicate() for those cases.
Does ioredis retry failed commands automatically?
It reconnects and can retry depending on options and command safety. Non-idempotent writes need an idempotency key; do not rely on automatic retries alone.
How should I handle Redis being unavailable?
Decide per use case: fail the request for a required store, or degrade to a database or cached default for a cache. Log and alert on connection errors.