Skip to main content

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 on batch()/abatch() per the BaseStore contract — only batch()/abatch() are implemented directly.
  • Per-item TTL (put(..., ttl=minutes)), backed by native Redis EXPIRE (one Redis key per item, so this doesn't depend on newer hash-field-TTL Redis versions). refresh_ttl is honored on get().
  • search()'s filter — 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/suffix matching 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_at preservation across overwrites. Every put() to an existing key currently resets both created_at and updated_at to the time of the write, rather than preserving the original created_at. Correct behavior would need a pre-read on every put; deferred for now.
  • refresh_ttl on search() is a no-op — only get() 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

Release files for langgraph-store-upstash 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langgraph-store-upstash 0.1.0
File Size Uploaded
langgraph_store_upstash-0.1.0.tar.gz 21.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langgraph-store-upstash 0.1.0
File Interpreter ABI Platform
langgraph_store_upstash-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 37.0 kB

Release files / langgraph_store_upstash-0.1.0.tar.gz

Download URL langgraph_store_upstash-0.1.0.tar.gz
Size 21.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e9766c08ea89d70b8eeb880f9a4208ce0ef8bc6a0e4048c775898d5e5a221164
BLAKE2b-256 checksum
How to use checksums
4dadea1af729a02ff5ba18f861a30e795b66f371ae089476b57af274a58647ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.0

Release files / langgraph_store_upstash-0.1.0-py3-none-any.whl

Download URL langgraph_store_upstash-0.1.0-py3-none-any.whl
Size 15.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7be538e73bcd2469cb9b03cbb7b9c24317413ae254a624b679da57c1fbccf9b5
BLAKE2b-256 checksum
How to use checksums
738f40f75f42c5643e747e555e579b25c89db20a5b243a54499119e3d19d28f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page