Skip to content

feat: Support Redis Cluster #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions langgraph/checkpoint/redis/aio.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,10 @@ async def __aexit__(
) -> None:
"""Async context manager exit."""
if self._owns_its_client:
await self._redis.aclose() # type: ignore[attr-defined]
await self._redis.connection_pool.disconnect()
await self._redis.aclose()
coro = self._redis.connection_pool.disconnect()
if coro:
await coro

# Prevent RedisVL from attempting to close the client
# on an event loop in a separate thread.
Expand Down
6 changes: 4 additions & 2 deletions langgraph/checkpoint/redis/ashallow.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ async def __aexit__(
tb: Optional[TracebackType],
) -> None:
if self._owns_its_client:
await self._redis.aclose() # type: ignore[attr-defined]
await self._redis.connection_pool.disconnect()
await self._redis.aclose()
coro = self._redis.connection_pool.disconnect()
if coro:
await coro

# Prevent RedisVL from attempting to close the client
# on an event loop in a separate thread.
Expand Down
14 changes: 7 additions & 7 deletions langgraph/checkpoint/redis/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def set_client_info(self) -> None:

try:
# Try to use client_setinfo command if available
self._redis.client_setinfo("LIB-NAME", __full_lib_name__) # type: ignore
self._redis.client_setinfo("LIB-NAME", __full_lib_name__)
except (ResponseError, AttributeError):
# Fall back to a simple echo if client_setinfo is not available
try:
Expand All @@ -174,7 +174,7 @@ async def aset_client_info(self) -> None:

try:
# Try to use client_setinfo command if available
await self._redis.client_setinfo("LIB-NAME", client_info) # type: ignore
await self._redis.client_setinfo("LIB-NAME", client_info)
except (ResponseError, AttributeError):
# Fall back to a simple echo if client_setinfo is not available
try:
Expand Down Expand Up @@ -468,17 +468,17 @@ def put_writes(
# UPSERT case - only update specific fields
if key_exists:
# Update only channel, type, and blob fields
pipeline.set(key, "$.channel", write_obj["channel"]) # type: ignore[arg-type]
pipeline.set(key, "$.type", write_obj["type"]) # type: ignore[arg-type]
pipeline.set(key, "$.blob", write_obj["blob"]) # type: ignore[arg-type]
pipeline.set(key, "$.channel", write_obj["channel"])
pipeline.set(key, "$.type", write_obj["type"])
pipeline.set(key, "$.blob", write_obj["blob"])
else:
# For new records, set the complete object
pipeline.set(key, "$", write_obj) # type: ignore[arg-type]
pipeline.set(key, "$", write_obj)
created_keys.append(key)
else:
# INSERT case - only insert if doesn't exist
if not key_exists:
pipeline.set(key, "$", write_obj) # type: ignore[arg-type]
pipeline.set(key, "$", write_obj)
created_keys.append(key)

pipeline.execute()
Expand Down
4 changes: 2 additions & 2 deletions langgraph/checkpoint/redis/shallow.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,10 +555,10 @@ def put_writes(
pipeline.set(key, "$.blob", write_obj["blob"])
else:
# For new records, set the complete object
pipeline.set(key, "$", write_obj) # type: ignore[arg-type]
pipeline.set(key, "$", write_obj)
else:
# INSERT case
pipeline.set(key, "$", write_obj) # type: ignore[arg-type]
pipeline.set(key, "$", write_obj)

pipeline.execute()

Expand Down
Loading