-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Introduce Refined Redis Client Classes #4201
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
base: master
Are you sure you want to change the base?
Conversation
Test Results 253 files + 4 253 suites +4 10m 2s ⏱️ + 3m 3s Results for commit 92bd295. ± Comparison against base commit 8e60c1b. This pull request removes 4 and adds 81 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
So we don't need to implement them in RedisClient
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.
Pull Request Overview
This PR introduces three new Redis client classes with a unified builder pattern to simplify configuration and improve developer experience. Key changes include:
- Addition of
RedisClient
,RedisClusterClient
, andRedisSentinelClient
with builder-based APIs - Implementation of a shared
AbstractRedisClientBuilder
and removal of constructor explosion - Removal of deprecated command methods and definition of a
DEFAULT_DIALECT
constant
Reviewed Changes
Copilot reviewed 18 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/main/java/redis/clients/jedis/RedisClient.java | New standalone Redis client using builder pattern |
src/main/java/redis/clients/jedis/RedisClusterClient.java | New Redis Cluster client using builder pattern |
src/main/java/redis/clients/jedis/RedisSentinelClient.java | New Redis Sentinel client using builder pattern |
src/main/java/redis/clients/jedis/AbstractRedisClientBuilder.java | Shared base class for client builders |
src/main/java/redis/clients/jedis/CommandObjects.java | Updated default search dialect initialization |
src/main/java/redis/clients/jedis/search/SearchProtocol.java | Added DEFAULT_DIALECT constant |
src/main/java/redis/clients/jedis/search/RediSearchCommands.java | Removed deprecated search command overloads |
src/main/java/redis/clients/jedis/commands/StringCommands.java | Removed deprecated getSet methods |
src/main/java/redis/clients/jedis/commands/StringBinaryCommands.java | Removed deprecated getSet binary overload |
src/main/java/redis/clients/jedis/commands/StreamBinaryCommands.java | Removed deprecated xread and xreadGroup methods |
src/main/java/redis/clients/jedis/commands/SortedSetCommands.java | Removed deprecated zdiffStore methods |
src/main/java/redis/clients/jedis/commands/SortedSetBinaryCommands.java | Removed deprecated binary zdiffStore methods |
src/main/java/redis/clients/jedis/commands/ClusterCommands.java | Removed deprecated cluster command methods |
src/test/java/redis/clients/jedis/RedisClientTest.java | Added comprehensive tests for RedisClient |
src/test/java/redis/clients/jedis/RedisClusterClientTest.java | Added unit tests for RedisClusterClient |
src/test/java/redis/clients/jedis/RedisSentinelClientTest.java | Added unit and integration tests for RedisSentinelClient |
src/test/java/redis/clients/jedis/AbstractRedisClientBuilderTest.java | Added tests for shared builder behavior |
Comments suppressed due to low confidence (2)
src/main/java/redis/clients/jedis/search/SearchProtocol.java:9
- [nitpick] Consider adding a JavaDoc comment for
DEFAULT_DIALECT
to explain its purpose and default value.
public static final int DEFAULT_DIALECT = 2;
src/main/java/redis/clients/jedis/AbstractRedisClientBuilder.java:147
- Currently only
searchDialect == 0
is disallowed; consider extending validation to reject negative or otherwise out-of-range dialect values (e.g.,searchDialect <= 0
).
public T searchDialect(int searchDialect) {
- Implement autocloseable interface in BaseRedisClient to use it in existing tests - Add MULTI methods in BaseRedisClient - Clean up builders - Add missing constructors
This PR introduces three new Redis client classes (
RedisClient
,RedisClusterClient
,RedisSentinelClient
) that provide a clean, developer-friendly API while addressing critical developer experience issues identified in the current Jedis architecture.Problem Statement
The current Jedis library suffers from significant developer experience issues:
Jedis
,JedisPooled
,JedisCluster
,UnifiedJedis
) with unclear distinctionsJedisPool
have 56+ constructors,JedisPooled
has 65+ constructors, creating analysis paralysisCurrent Architecture Problems
The diagram above shows the current problematic architecture with:
Solution
This PR introduces a new client architecture that addresses these issues through:
BaseRedisClient
New Architecture
The new architecture (green boxes) provides:
BaseRedisClient
containing all command implementationsBaseRedisClient (Abstract)
RedisClient (Standalone Redis)
BaseRedisClient
for command inheritancePooledConnectionProvider
for automatic connection managementRedisClusterClient (Redis Cluster)
BaseRedisClient
with cluster-specific functionalityClusterConnectionProvider
for slot-based routingRedisSentinelClient (Redis Sentinel)
BaseRedisClient
for Sentinel supportSentineledConnectionProvider
for automatic failoverBuilder Pattern Implementation
All new clients use a consistent builder pattern with shared configuration through
AbstractRedisClientBuilder
Future Work