InMemoryByteStore
This guide will help you get started with in-memory key-value stores. For detailed documentation of all InMemoryByteStore
features and configurations head to the API reference.
Overviewโ
The InMemoryByteStore
is a non-persistent implementation of a ByteStore
that stores everything in a Python dictionary. It's intended for demos and cases where you don't need persistence past the lifetime of the Python process.
Integration detailsโ
Class | Package | Local | JS support | Package downloads | Package latest |
---|---|---|---|---|---|
InMemoryByteStore | langchain_core | โ | โ |
Installationโ
The LangChain InMemoryByteStore
integration lives in the langchain_core
package:
%pip install -qU langchain_core
Instantiationโ
Now you can instantiate your byte store:
from langchain_core.stores import InMemoryByteStore
kv_store = InMemoryByteStore()
Usageโ
You can set data under keys like this using the mset
method:
kv_store.mset(
[
["key1", b"value1"],
["key2", b"value2"],
]
)
kv_store.mget(
[
"key1",
"key2",
]
)
[b'value1', b'value2']
And you can delete data using the mdelete
method:
kv_store.mdelete(
[
"key1",
"key2",
]
)
kv_store.mget(
[
"key1",
"key2",
]
)
[None, None]
API referenceโ
For detailed documentation of all InMemoryByteStore
features and configurations, head to the API reference: https://api.python.langchain.com/en/latest/stores/langchain_core.stores.InMemoryByteStore.html