feat(cdk-axum): support redis-cluster for caching#1936
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1936 +/- ##
=======================================
Coverage 65.16% 65.17%
=======================================
Files 330 330
Lines 56742 56734 -8
=======================================
Hits 36976 36976
+ Misses 19766 19758 -8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
asmogo
left a comment
There was a problem hiding this comment.
Thanks for this contribution. Do you think we can reuse the redis cluster connection instead of creating a new connection for every set / get call on the cluster instance?
|
Please rebase and not merge https://github.com/cashubtc/cdk/blob/main/DEVELOPMENT.md#keeping-your-branch-up-to-date |
thesimplekid
left a comment
There was a problem hiding this comment.
A few comments and can you squash commits.
86d5220 to
9042f8a
Compare
|
Code looks good. Waiting on testing and approval from @asmogo |
any changes ? |
- Add redis cluster client configuration logic - Refactor redis configuration into environment parser - Update redis dependencies to use ConnectionManager and exclude default features
|
I got some panics with your current implementation on the mintd startup. requesting some changes here. |
|
Panics stem from the use of block on. title: "Panics in HttpCache initialization due to nested block_on calls"
|
|
@GEET3001 This paniced pretty early, did you run or test this code yourself? |
closes #1578
Description
This PR adds support for Redis Cluster and Valkey Cluster to the cdk-axum HTTP caching backend.
Currently, the cache only supports a single-node Redis connection, which fails in clustered environments because it cannot handle "MOVED" redirections. This change introduces a cluster-aware client that automatically routes requests to the correct nodes and handles cluster topology changes.
Key Changes
1.Introduced RedisClient enum to support both Standard and Cluster connection types.
2. Added cluster and cluster-async features to the redis dependency.
3. Updated HttpCacheRedis to use the appropriate connection methods for both single-node and cluster setups.
4. Added support for cluster configuration via environment variables:
CDK_MINTD_CACHE_REDIS_USE_CLUSTER: Enable cluster mode.
CDK_MINTD_CACHE_REDIS_CLUSTER_NODES: Comma-separated list of node URLs.
Notes to the reviewers
2 . The HttpCache::from(config) logic in mod.rs now intelligently selects the client type based on the provided configuration.
Suggested CHANGELOG Updates
CHANGED
ADDED
Redis Cluster and Valkey support for HTTP caching in cdk-axum.
New environment variables for cluster configuration: CDK_MINTD_CACHE_REDIS_USE_CLUSTER and CDK_MINTD_CACHE_REDIS_CLUSTER_NODES.
REMOVED
FIXED
Cache failures in clustered Redis/Valkey environments due to lack of redirection handling.
Checklist
crates/cdk-ffi)— N/A (Mint-side cache change only)