Skip to main content

UpstashRedisByteStore

The UpstashRedisStore is an implementation of ByteStore that stores everything in your Upstash-hosted Redis instance.

To use the base RedisStore instead, see this guide

To configure Upstash Redis, follow our Upstash guide.

%pip install --upgrade --quiet  upstash-redis
from langchain_community.storage import UpstashRedisByteStore
from upstash_redis import Redis

URL = "<UPSTASH_REDIS_REST_URL>"
TOKEN = "<UPSTASH_REDIS_REST_TOKEN>"

redis_client = Redis(url=URL, token=TOKEN)
store = UpstashRedisByteStore(client=redis_client, ttl=None, namespace="test-ns")

store.mset([("k1", b"v1"), ("k2", b"v2")])
print(store.mget(["k1", "k2"]))
API Reference:UpstashRedisByteStore
[b'v1', b'v2']

Was this page helpful?


You can leave detailed feedback on GitHub.