Skip to content

Update Config.Client to redis.UniversalClient for Cluster Support (#24)#26

Merged
VojtechVitek merged 2 commits into
go-chi:masterfrom
namigaliyev:master
Jun 11, 2025
Merged

Update Config.Client to redis.UniversalClient for Cluster Support (#24)#26
VojtechVitek merged 2 commits into
go-chi:masterfrom
namigaliyev:master

Conversation

@namigaliyev

Copy link
Copy Markdown
Contributor

This PR updates the Config.Client field in httprateredis.Config from *redis.Client to redis.UniversalClient to enable support for Redis cluster mode via *redis.ClusterClient, addressing issue #24.

Motivation:

  • The current *redis.Client type limits httprateredis to single Redis instances, causing type mismatch errors when using *redis.ClusterClient
  • redis.UniversalClient is a flexible interface supporting both *redis.Client (single instance), *redis.ClusterClient (cluster mode), and *redis.Ring (sharded Redis), making it suitable for broader use cases.

Changes:

  • Changed Config.Client in config.go from *redis.Client to redis.UniversalClient.
  • No modifications to rate-limiting logic, as all Redis commands (e.g., INCR, EXPIRE, GET) are supported by redis.UniversalClient.

Impact:

  • Enables httprateredis to work seamlessly with Redis cluster mode, addressing community demand in Allow other go-redis client implementations #24.
  • Maintains full compatibility with existing *redis.Client usage for single-instance Redis.
  • Enhances flexibility for other redis.UniversalClient implementations.

Comment thread config.go Outdated
@namigaliyev

namigaliyev commented Apr 16, 2025

Copy link
Copy Markdown
Contributor Author

@VojtechVitek @pkieltyka hello, please help to review this, thanks

@VojtechVitek VojtechVitek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

Thank you for your contribution :)

@VojtechVitek VojtechVitek merged commit f9e22d7 into go-chi:master Jun 11, 2025
@shawnstephens

Copy link
Copy Markdown

@namigaliyev Thank you!

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.

4 participants