Memory
In-memory state adapter for local development and tests. State is lost on restart and locks don't work across instances — never use it in production.
The memory adapter is for local development and testing only. State is lost on restart, and distributed locks don't work across multiple instances. Use @chat-adapter/state-redis, @chat-adapter/state-ioredis, or @chat-adapter/state-pg in production.
Install
pnpm add @chat-adapter/state-memoryQuick start
import { Chat } from "chat";
import { createMemoryState } from "@chat-adapter/state-memory";
const bot = new Chat({
userName: "mybot",
adapters: { /* ... */ },
state: createMemoryState(),
});createMemoryState() takes no arguments. Subscriptions, locks, and cache live in the current process and disappear when the process exits.
When to use
- Local development against
pnpm --filter docs devor your example app. - Unit tests that need a real
StateAdapterinterface without a Redis or Postgres dependency. - Quick prototypes where persistence isn't on the critical path.
Feature support
Capabilities
| Feature | Supported |
|---|---|
| Persistence | |
| Multi-instance | |
| Subscriptions | In-memory |
| Distributed locking | Single process |
| Key-value caching | In-memory |
| Lists | |
| Queues | |
| Automatic reconnect | |
| Cluster support | |
| Sentinel support | |
| Key prefix namespacing |