Skip to content

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Support Redis Cluster #35

wants to merge 5 commits into from

Conversation

abrookins
Copy link
Contributor

Add support for Redis Cluster/Redis Enterprise:

  1. Detect when the client is connected to a Redis Cluster or Enterprise node
  2. If using Cluster, add hash tags to keys so that Redis stores keys that are logically grouped in the same 'slot,' allowing for multi-key operations.
  3. If using Cluster, always set transaction=False when running pipelines.

@abrookins abrookins requested a review from Copilot May 1, 2025 22:16
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@abrookins abrookins marked this pull request as draft May 1, 2025 22:17
@abrookins abrookins requested a review from Copilot May 2, 2025 16:07
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for Redis Cluster by detecting cluster mode, adding key hash tagging for key grouping, and ensuring that Redis pipelines run with transaction disabled in cluster mode.

  • Detect cluster mode on client initialization
  • Integrate key hashing via get_key_with_hash_tag
  • Adjust pipeline creation to use transaction=not cluster_mode for TTL and search operations

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_cluster_mode.py Introduces tests for sync cluster detection, key hash tagging, and pipeline transaction setting
tests/test_async_cluster_mode.py Introduces tests for async cluster detection and key hash tagging with appropriate pipeline behavior
langgraph/store/redis/base.py Adds get_key_with_hash_tag function and detects cluster mode in init with corresponding pipeline adjustments
langgraph/store/redis/aio.py Updates async pipeline creation to use cluster mode flag in TTL and search operations
langgraph/store/redis/init.py Adapts synchronous store operations to handle key hash tagging and pipeline configuration for cluster mode
Comments suppressed due to low confidence (1)

langgraph/store/redis/aio.py:213

  • [nitpick] In the vector search branch, the pipeline is created with a fixed transaction=False. For consistency with other usage (i.e. transaction=not self.cluster_mode), consider aligning this parameter to improve maintainability.
pipeline = self._redis.pipeline(transaction=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant