-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix how hash slot assignment is retrieved and stored
Previously, the `RedisClusterClient` used to obtain the hash slot assignment as the first step of each `connect()` call. This is fairly expensive and increases the load on the first endpoint in the list (because we target the first endpoint when issuing `CLUSTER SLOTS`). It is also unnecessary. Redis always sends a redirection when the node to which a command is sent is not assigned the hash slot targetted by the command. Until we observe such redirection, the hash slot assignment we observed before is still valid. Hence, we can store the hash slot assignment in the `RedisClusterClient` and reuse it for all `RedisClusterConnection` objects, until the `MOVED` error is seen. In such case, we reset the hash slot assignment so that the next `connect()` call fetches it again.
- Loading branch information
Showing
2 changed files
with
88 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters