LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
React SDK
Vue SDK
Svelte SDK
Angular SDK
LangGraph SDK
  • Ui
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Utils
  • Server
  • Stream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
  • Store
LangGraph Checkpoint Redis
  • Shallow
  • Store
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
  • Cli
LangGraph API
LangGraph CLI
LangGraph CUA
  • Utils
LangGraph Supervisor
LangGraph Swarm
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangGraph
WebChannelsPregelPrebuiltRemote
React SDK
Vue SDK
Svelte SDK
Angular SDK
LangGraph SDK
UiClientAuthReactLoggingReact UiUtilsServerStream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
Store
LangGraph Checkpoint Redis
ShallowStore
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
Cli
LangGraph API
LangGraph CLI
LangGraph CUA
Utils
LangGraph Supervisor
LangGraph Swarm
Language
Theme
JavaScript@langchain/langgraphwebInMemoryStore
Class●Since v0.3

InMemoryStore

Copy
class InMemoryStore

Bases

BaseStore

Used in Docs

  • Context engineering in Deep Agents
  • Memory
  • Memory
  • Prebuilt middleware
  • Tools

Constructors

Properties

Methods

Inherited fromBaseStore

Methods

Mbatch→ Promise<OperationResults<Op>>
—

Execute multiple operations in a single batch.

Mdelete→ Promise<void>
—

Delete an item from the store.

Mget→ Value
—

Return the current value of the channel.

M
View source on GitHub
listNamespaces
→ Promise<string[][]>
—

List and filter namespaces in the store.

Mput→ Promise<void>
—

Store or update an item.

Msearch→ Promise<Item[]>
—

Search for items within a namespace prefix.

Mstart
—

Start the store. Override if initialization is needed.

Mstop→ Promise<void>
—

Stop the store. Override if cleanup is needed.

Example

constructor
constructor
property
indexConfig: IndexConfig | undefined
method
batch→ Promise<OperationResults<Op>>
method
delete→ Promise<void>
method
get→ Value
method
listNamespaces→ Promise<string[][]>
method
put→ Promise<void>
method
search→ Promise<Item[]>
method
start
method
stop→ Promise<void>

In-memory key-value store with optional vector search.

A lightweight store implementation using JavaScript Maps. Supports basic key-value operations and vector search when configured with embeddings.

Execute multiple operations in a single batch. This is more efficient than executing operations individually.

Delete an item from the store.

Return the current value of the channel.

List and filter namespaces in the store. Used to explore data organization and navigate the namespace hierarchy.

Store or update an item.

Search for items within a namespace prefix. Supports both metadata filtering and vector similarity search.

Start the store. Override if initialization is needed.

Stop the store. Override if cleanup is needed.

Copy
// Basic key-value storage
const store = new InMemoryStore();
await store.put(["users", "123"], "prefs", { theme: "dark" });
const item = await store.get(["users", "123"], "prefs");

// Vector search with embeddings
import { OpenAIEmbeddings } from "@langchain/openai";
const store = new InMemoryStore({
  index: {
    dims: 1536,
    embeddings: new OpenAIEmbeddings({ modelName: "text-embedding-3-small" }),
  }
});

// Store documents
await store.put(["docs"], "doc1", { text: "Python tutorial" });
await store.put(["docs"], "doc2", { text: "TypeScript guide" });

// Search by similarity
const results = await store.search(["docs"], { query: "python programming" });