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