plugins/plugin-inmemorydb/README.md
A pure in-memory, ephemeral database adapter for elizaOS. All data is completely lost on process restart or when close() is called.
IDatabaseAdapter interfaceThis plugin is ideal for:
Not recommended for:
bun add @elizaos/plugin-inmemorydb
import { plugin } from "@elizaos/plugin-inmemorydb";
// Add to your agent configuration
const agent = {
plugins: [plugin],
// ...
};
import { plugin } from "@elizaos/plugin-inmemorydb";
// Add to your agent configuration
const agent = {
plugins: [plugin],
// ...
};
import {
InMemoryDatabaseAdapter,
MemoryStorage,
} from "@elizaos/plugin-inmemorydb";
const storage = new MemoryStorage();
const adapter = new InMemoryDatabaseAdapter(storage, agentId);
await adapter.init();
// Use the adapter...
// When done, close to clear all data
await adapter.close();
// Clear all data (adapter still usable)
await storage.clear();
// Or close the adapter entirely (also clears data)
await adapter.close();
| Feature | plugin-inmemorydb | plugin-localdb | plugin-sql |
|---|---|---|---|
| Persistence | None (ephemeral) | JSON files | PostgreSQL |
| Setup | Zero configuration | Zero configuration | Requires PostgreSQL |
| Data on restart | Lost | Preserved | Preserved |
| Best for | Testing/dev | Local dev | Production |
The plugin uses simple JavaScript Map data structures to store all data:
Memory
├── Collections (Map<string, Map<string, unknown>>)
│ ├── agents: Map<id, agent>
│ ├── memories: Map<id, memory>
│ ├── rooms: Map<id, room>
│ └── ... (other collections)
└── HNSW Vector Index (in-memory)
When the process ends or close() is called, all Maps are cleared and data is gone forever.
The plugin includes an ephemeral HNSW (Hierarchical Navigable Small World) implementation for vector similarity search:
The vector index is also purely in-memory and is cleared with all other data.
MIT