> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-docs-zh.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# InMemoryByteStore 集成

> 使用 LangChain Python 集成 InMemoryByteStore 存储。

本指南将帮助你开始使用内存中的[key-value存储](https://langchain-docs-zh.mintlify.site/langchain/oss/python/integrations/stores.md)。有关所有`InMemoryByteStore`功能和配置的详细文档，请访问[API参考](https://reference.langchain.com/python/langchain-core/stores/InMemoryByteStore)。

## 概述

`InMemoryByteStore`是一个非持久的\[key-value存储]`ByteStore`实现，它将所有内容存储在Python字典中。它适用于演示和不需要持久化到Python进程生命周期的场景。

### 集成细节

| 类 | 包 | 本地 | [JS支持](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/stores/in_memory.md) | 下载 | 版本 |
| :- | :- | :-: | :-: | :-: | :-: |
| [`InMemoryByteStore`](https://reference.langchain.com/python/langchain-core/stores/InMemoryByteStore) | [`langchain-core`](https://reference.langchain.com/python/langchain-core) | ✅ | ✅ | ![PyPI - 下载](https://img.shields.io/pypi/dm/langchain_core?style=flat-square\&label=%20) | ![PyPI - 版本](https://img.shields.io/pypi/v/langchain_core?style=flat-square\&label=%20) |

### 安装

LangChain `InMemoryByteStore`集成位于`langchain-core`包中：

```python theme={null}
pip install -qU langchain-core
```

## 实例化

现在你可以实例化你的字节存储：

```python theme={null}
from langchain_core.stores import InMemoryByteStore

kv_store = InMemoryByteStore()
```

## 使用

你可以使用`mset`方法像这样在键下设置数据：

```python theme={null}
kv_store.mset(
    [
        ["key1", b"value1"],
        ["key2", b"value2"],
    ]
)

kv_store.mget(
    [
        "key1",
        "key2",
    ]
)
```

```text theme={null}
[b'value1', b'value2']
```

并且你可以使用`mdelete`方法删除数据：

```python theme={null}
kv_store.mdelete(
    [
        "key1",
        "key2",
    ]
)

kv_store.mget(
    [
        "key1",
        "key2",
    ]
)
```

```text theme={null}
[None, None]
```

***

## API参考

有关所有`InMemoryByteStore`功能和配置的详细文档，请访问[API参考](https://reference.langchain.com/python/langchain-core/stores/InMemoryByteStore)

***

> 官方原文：[src/oss/python/integrations/stores/in\_memory.mdx](https://github.com/langchain-ai/docs/blob/main/src/oss/python/integrations/stores/in_memory.mdx) · 非官方翻译，译文由 AI 生成，以英文原文为准。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.