ioredis

Alternative Redis state adapter for Chat SDK built on ioredis — use this if you already depend on ioredis or need Cluster/Sentinel support.

Install

pnpm add @chat-adapter/state-ioredis

Quick start

lib/bot.ts
import { Chat } from "chat";
import { createIORedisState } from "@chat-adapter/state-ioredis";

const bot = new Chat({
  userName: "mybot",
  adapters: { /* ... */ },
  state: createIORedisState({ url: process.env.REDIS_URL! }),
});

Configuration

Prop

Type

Either url or client is required.

Advanced

Using an existing client

lib/state.ts
import Redis from "ioredis";
import { createIORedisState } from "@chat-adapter/state-ioredis";

const client = new Redis("redis://localhost:6379");

export const state = createIORedisState({ client });

When to choose ioredis vs redis

Use @chat-adapter/state-ioredis when:

  • You already use ioredis in your project.
  • You need Redis Cluster support.
  • You need Redis Sentinel support.
  • You prefer the ioredis API.

Use @chat-adapter/state-redis when:

  • You want the official Redis client.
  • You're starting a new project.
  • You don't need Cluster or Sentinel.

Key structure

{keyPrefix}:subscriptions     - SET of subscribed thread IDs
{keyPrefix}:lock:{threadId}   - Lock key with TTL

Feature support

Capabilities

FeatureSupported
Persistence
Multi-instance
Subscriptions
Distributed locking
Key-value caching
Lists
Queues
Automatic reconnect
Cluster support
Sentinel support
Key prefix namespacing

On this page