# InMemoryStore

> **Class** in `langgraph.store`

📖 [View in docs](https://reference.langchain.com/python/langgraph.store/memory/InMemoryStore)

In-memory dictionary-backed store with optional vector search.

!!! example "Examples"
    Basic key-value storage:
        store = InMemoryStore()
        store.put(("users", "123"), "prefs", {"theme": "dark"})
        item = store.get(("users", "123"), "prefs")

    Vector search with embeddings:
        from langchain.embeddings import init_embeddings
        store = InMemoryStore(index={
            "dims": 1536,
            "embed": init_embeddings("openai:text-embedding-3-small"),
            "fields": ["text"],
        })

        # Store documents
        store.put(("docs",), "doc1", {"text": "Python tutorial"})
        store.put(("docs",), "doc2", {"text": "TypeScript guide"})

        # Search by similarity
        results = store.search(("docs",), query="python programming")

## Signature

```python
InMemoryStore(
    self,
    *,
    index: IndexConfig | None = None,
)
```

## Description

**Note:**

Semantic search is disabled by default. You can enable it by providing an `index` configuration
when creating the store. Without this configuration, all `index` arguments passed to
`put` or `aput`will have no effect.

**Warning:**

This store keeps all data in memory. Data is lost when the process exits.
For persistence, use a database-backed store like PostgresStore.

**Tip:**

For vector search, install numpy for better performance:
```bash
pip install numpy
```

## Extends

- `BaseStore`

## Constructors

```python
__init__(
    self,
    *,
    index: IndexConfig | None = None,
) -> None
```

| Name | Type |
|------|------|
| `index` | `IndexConfig \| None` |


## Properties

- `index_config`
- `embeddings`

## Methods

- [`batch()`](https://reference.langchain.com/python/langgraph.store/memory/InMemoryStore/batch)
- [`abatch()`](https://reference.langchain.com/python/langgraph.store/memory/InMemoryStore/abatch)

---

[View source on GitHub](https://github.com/langchain-ai/langgraph/blob/916025d2f6d9f6ddb2628bd248bc4f3db632d9a8/libs/checkpoint/langgraph/store/memory/__init__.py#L136)