GeezerVison is showing github.com — Expose renewSlotCache on JedisCluster as public API by agarwalbharat · Pull Request #4555 · redis/jedis
Conversation
agarwalbharat
commented
Jun 2, 2026
•
edited by ggivo
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jedis already supports refreshing the Redis Cluster slot cache internally through ClusterConnectionProvider.renewSlotCache(), but callers directly using do not have a public API to trigger that refresh directly.
This is useful for applications that detect stale or incomplete cluster topology state outside the normal command retry path, especially for direct slot/node workflows such as getConnectionFromSlot().
Add JedisCluster#refreshClusterTopology() as a public API that delegates to the existing ClusterConnectionProvider renewal path.
This gives applications an explicit way to refresh the in-memory cluster slot cache when they detect stale topology state outside the normal command retry flow.
Closes : #4154
Note Low Risk
Thin public wrapper over existing renewal logic; no new topology algorithm, only broader caller access to a path already used internally.
Overview
Adds refreshClusterTopology() on JedisCluster and RedisClusterClient, exposing a way for apps to force an in-memory cluster topology refresh (nodes and slot map) by delegating to the existing ClusterConnectionProvider#renewSlotCache() path—intended when stale routing is noticed outside normal command retries, e.g. before getConnectionFromSlot(int).
Unit tests assert both clients call renewSlotCache() on the provider (mocked JedisCluster constructor and RedisClusterClient builder).
Reviewed by Cursor Bugbot for commit 1bcab78. Bugbot is set up for automated code reviews on this repo. Configure here.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.

Reviewed by Cursor Bugbot for commit ac634ee. Configure here.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks @agarwalbharat - One naming change before merge.
Rename the public renewSlotCache() → refreshClusterTopology().
It refreshes the full topology (nodes + primary/replica slots), not just a slot cache, and it matches the existing TopologyRefresh* naming already in the codebase. Since this is a permanent public API, worth getting the name right.
/**
* Forces an immediate refresh of the in-memory Redis Cluster topology
* (node map, primary and replica slot assignments).
* <p>
* Useful before {@link #getConnectionFromSlot(int)} when stale topology is
* detected outside the command retry path. Best-effort; a no-op if a refresh
* is already in progress.
*/
public void refreshClusterTopology() {
((ClusterConnectionProvider) provider).renewSlotCache();
}
Same on both JedisCluster and RedisClusterClient;
Thanks again!
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add JedisCluster#refreshClusterTopology() as a public API that delegates to the existing ClusterConnectionProvider renewal path. This gives applications an explicit way to refresh the in-memory cluster slot cache when they detect stale topology state outside the normal command retry flow.
|
Thank you @ggivo for the review.
I have updated function as per suggestion.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
ggivo
ggivo approved these changes
+1 more reviewer
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|