RedisStore
This will help you get started with Redis key-value stores. For detailed documentation of all RedisStore
features and configurations head to the API reference.
Overview
The RedisStore
is an implementation of ByteStore
that stores everything in your Redis instance.
Integration details
Class | Package | Local | JS support | Package downloads | Package latest |
---|---|---|---|---|---|
RedisStore | langchain_community | ✅ | ✅ |
Setup
To create a Redis byte store, you'll need to set up a Redis instance. You can do this locally or via a provider - see our Redis guide for an overview of options.
Installation
The LangChain RedisStore
integration lives in the langchain_community
package:
%pip install -qU langchain_community redis
Instantiation
Now we can instantiate our byte store:
from langchain_community.storage import RedisStore
kv_store = RedisStore(redis_url="redis://localhost:6379")
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 RedisStore
features and configurations, head to the API reference: https://python.langchain.com/api_reference/community/storage/langchain_community.storage.redis.RedisStore.html