ioredis

5.10.1 · maintenance · verified Sat Apr 18

ioredis is a robust, performance-focused, and full-featured Redis client for Node.js, supporting Redis versions 2.6.12 up to the latest. Currently at stable version 5.10.1, the project is in a maintenance phase with contributions being evaluated, but `node-redis` is recommended for new projects. It offers support for Redis Cluster, Sentinel, Streams, Pipelining, Lua scripting, Pub/Sub, and includes official TypeScript declarations.

Common errors

Warnings

Install

Imports

Quickstart

Connects to a Redis instance, sets a key-value pair, and retrieves it, demonstrating basic client usage.

import { Redis } from 'ioredis';

async function run() {
  const redis = new Redis(process.env.REDIS_URL ?? 'redis://localhost:6379');

  try {
    await redis.set('mykey', 'Hello ioredis!');
    const value = await redis.get('mykey');
    console.log(`Retrieved value: ${value}`);
  } catch (error) {
    console.error('Redis operation failed:', error);
  } finally {
    redis.disconnect();
  }
}

run();

view raw JSON →