# InMemoryStore

> **Class** in `@langchain/core`

📖 [View in docs](https://reference.langchain.com/javascript/langchain-core/stores/InMemoryStore)

In-memory implementation of the BaseStore using a dictionary. Used for
storing key-value pairs in memory.

## Signature

```javascript
class InMemoryStore
```

## Extends

- `BaseStore<string, T>`

## Constructors

- [`constructor()`](https://reference.langchain.com/javascript/langchain-core/stores/InMemoryStore/constructor)

## Properties

- `lc_kwargs`
- `lc_namespace`
- `lc_serializable`
- `store`
- `lc_aliases`
- `lc_attributes`
- `lc_id`
- `lc_secrets`
- `lc_serializable_keys`

## Methods

- [`mdelete()`](https://reference.langchain.com/javascript/langchain-core/stores/InMemoryStore/mdelete)
- [`mget()`](https://reference.langchain.com/javascript/langchain-core/stores/InMemoryStore/mget)
- [`mset()`](https://reference.langchain.com/javascript/langchain-core/stores/InMemoryStore/mset)
- [`toJSON()`](https://reference.langchain.com/javascript/langchain-core/stores/InMemoryStore/toJSON)
- [`toJSONNotImplemented()`](https://reference.langchain.com/javascript/langchain-core/stores/InMemoryStore/toJSONNotImplemented)
- [`yieldKeys()`](https://reference.langchain.com/javascript/langchain-core/stores/InMemoryStore/yieldKeys)
- [`lc_name()`](https://reference.langchain.com/javascript/langchain-core/stores/InMemoryStore/lc_name)

## Examples

```typescript
const store = new InMemoryStore<BaseMessage>();
await store.mset(
  Array.from({ length: 5 }).map((_, index) => [
    `message:id:${index}`,
    index % 2 === 0
      ? new AIMessage("ai stuff...")
      : new HumanMessage("human stuff..."),
  ]),
);

const retrievedMessages = await store.mget(["message:id:0", "message:id:1"]);
await store.mdelete(await store.yieldKeys("message:id:").toArray());
```

---

[View source on GitHub](https://github.com/langchain-ai/langchainjs/blob/62fc484b2a0d1ec5b8bebff4a8a0efe6300ada72/libs/langchain-core/src/stores.ts#L56)