langgraph-store-upstash
A LangGraph BaseStore
implementation backed by Upstash Redis — talks to
Redis exclusively over its REST API (upstash-redis), so it works from
serverless/edge runtimes that can't hold a TCP connection open.
See DESIGN.md for the Redis key schema and the reasoning
behind the batch()/abatch() dispatcher — Upstash's REST client has no
RediSearch, no vector index, and no automatic JSON serialization, so the
schema looks different from the official Postgres/Redis-TCP stores.
Install
pip install langgraph-store-upstash
Usage
Sync
from langgraph_store_upstash import UpstashStore
store = UpstashStore(url="UPSTASH_REDIS_REST_URL", token="UPSTASH_REDIS_REST_TOKEN")
# or: store = UpstashStore.from_env() # reads the same two env vars
store.put(("documents", "user123"), "report1", {"memory": "Will likes ai"})
store.get(("documents", "user123"), "report1")
store.search(("documents",), filter={"memory": {"$ne": None}})
store.list_namespaces(prefix=("documents",))
store.delete(("documents", "user123"), "report1")
Async
from langgraph_store_upstash.aio import AsyncUpstashStore
store = AsyncUpstashStore.from_env()
await store.aput(("documents", "user123"), "report1", {"memory": "Will likes ai"})
await store.aget(("documents", "user123"), "report1")
Both classes also accept an existing client instead of url/token:
from upstash_redis import Redis
from langgraph_store_upstash import UpstashStore
store = UpstashStore(client=Redis(url=..., token=...))
What's implemented
get/put/delete/search/list_namespaces(+ async equivalents), all built onbatch()/abatch()per theBaseStorecontract — onlybatch()/abatch()are implemented directly.- Per-item TTL (
put(..., ttl=minutes)), backed by native RedisEXPIRE(one Redis key per item, so this doesn't depend on newer hash-field-TTL Redis versions).refresh_ttlis honored onget(). search()'sfilter— one operator per field ($eq,$ne,$gt,$gte,$lt,$lte), applied client-side after fetching candidates from a namespace-prefix-narrowed Redis range scan.list_namespaces()—prefix/suffixmatching including"*"wildcard segments,max_depth,limit/offset, matching LangGraph's reference stores' dedupe-then-sort-then-paginate behavior.
What's not (yet) implemented
- Semantic search.
search(..., query=...)is accepted but ignored — plain Upstash Redis has no vector index (Upstash's Vector product is a separate service/client).IndexConfig/embeddings aren't wired up. created_atpreservation across overwrites. Everyput()to an existing key currently resets bothcreated_atandupdated_atto the time of the write, rather than preserving the originalcreated_at. Correct behavior would need a pre-read on every put; deferred for now.refresh_ttlonsearch()is a no-op — onlyget()currently refreshes TTLs on read.- Suffix matching in
list_namespaces()is O(namespace count), not indexed — it scans the full namespace index and filters client-side, since a forward-sorted Redis sorted set can't do an efficient suffix range query the way it can for prefixes. Namespace cardinality is expected to stay well below item cardinality, so this is intended to stay cheap in practice; DESIGN.md documents the reverse-index alternative that was considered and deferred.
Testing
pip install -e ".[dev]"
pytest tests/test_shared.py -v # no network required
# optional: full read/write test against a real Upstash database
export UPSTASH_REDIS_REST_URL="https://<db>.upstash.io"
export UPSTASH_REDIS_REST_TOKEN="<token>"
pytest tests/test_live_integration.py -v
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langgraph_store_upstash-0.1.0.tar.gz.
File metadata
- Download URL: langgraph_store_upstash-0.1.0.tar.gz
- Upload date:
- Size: 21.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9766c08ea89d70b8eeb880f9a4208ce0ef8bc6a0e4048c775898d5e5a221164
|
|
| MD5 |
0a68b066491968485c88aac75868204d
|
|
| BLAKE2b-256 |
4dadea1af729a02ff5ba18f861a30e795b66f371ae089476b57af274a58647ee
|
File details
Details for the file langgraph_store_upstash-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langgraph_store_upstash-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7be538e73bcd2469cb9b03cbb7b9c24317413ae254a624b679da57c1fbccf9b5
|
|
| MD5 |
68fa660b250c4a87ca2dbad53ec0e8cc
|
|
| BLAKE2b-256 |
738f40f75f42c5643e747e555e579b25c89db20a5b243a54499119e3d19d28f5
|