Skip to main content
本指南将帮助你快速上手内存键值存储。有关 InMemoryByteStore 所有特性和配置的详细文档,请参阅 API 参考

概述

InMemoryByteStoreByteStore 的非持久化实现,将所有内容存储在一个 Python 字典中。适用于演示场景或不需要在 Python 进程生命周期之外保留数据的情况。

集成详情

本地支持JS 支持下载量版本
InMemoryByteStorelangchain-corePyPI - DownloadsPyPI - Version

安装

LangChain InMemoryByteStore 集成位于 langchain-core 包中:
pip install -qU langchain-core

实例化

现在可以实例化字节存储:
from langchain_core.stores import InMemoryByteStore

kv_store = InMemoryByteStore()

使用方法

可以使用 mset 方法在键下设置数据:
kv_store.mset(
    [
        ["key1", b"value1"],
        ["key2", b"value2"],
    ]
)

kv_store.mget(
    [
        "key1",
        "key2",
    ]
)
[b'value1', b'value2']
可以使用 mdelete 方法删除数据:
kv_store.mdelete(
    [
        "key1",
        "key2",
    ]
)

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

API 参考

有关 InMemoryByteStore 所有特性和配置的详细文档,请参阅 API 参考:python.langchain.com/api_reference/core/stores/langchain_core.stores.InMemoryByteStore.html