InMemoryByteStore
本指南将帮助您开始使用内存中的键值存储。有关 InMemoryByteStore 所有功能和配置的详细文档,请参阅API 参考。
概览
InMemoryByteStore 是 ByteStore 的一个非持久化实现,它将所有内容存储在 Python 字典中。它适用于演示和不需要在 Python 进程生命周期之外进行持久化的场景。
集成详情
| 类 | 包 | 本地 | JS 支持 | 包下载量 | 包最新版本 |
|---|---|---|---|---|---|
| InMemoryByteStore | langchain_core | ✅ | ✅ |
安装
LangChain 的 InMemoryByteStore 集成位于 langchain_core 包中:
%pip install -qU langchain_core
实例化
现在您可以实例化您的 byte store:
from langchain_core.stores import InMemoryByteStore
kv_store = InMemoryByteStore()
API Reference: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 参考:https://python.langchain.com/api_reference/core/stores/langchain_core.stores.InMemoryByteStore.html
Related
- Key-value store conceptual guide