Skip to content

Commit 976e70f

Browse files
uglideCopilot
andcommitted
Apply suggestions from code review
Co-authored-by: Copilot <[email protected]>
1 parent bf4b967 commit 976e70f

File tree

3 files changed

+77
-3
lines changed

3 files changed

+77
-3
lines changed

src/main/java/redis/clients/jedis/RedisClient.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,30 @@
1010
import redis.clients.jedis.util.JedisURIHelper;
1111
import redis.clients.jedis.util.Pool;
1212

13+
/**
14+
* {@code RedisClient} is the recommended client for connecting to standalone Redis deployments.
15+
* <p>
16+
* This class provides a modern, unified interface for interacting with Redis, supporting
17+
* connection pooling, authentication, and configuration via a fluent builder API.
18+
* </p>
19+
* <p>
20+
* {@code RedisClient} supersedes the deprecated {@link JedisPooled} and {@link UnifiedJedis}
21+
* classes, offering improved usability and extensibility. For new applications, use
22+
* {@code RedisClient} instead of the older classes.
23+
* </p>
24+
* <p>
25+
* Example usage:
26+
* <pre>{@code
27+
* RedisClient client = RedisClient.builder()
28+
* .host("localhost")
29+
* .port(6379)
30+
* .build();
31+
* }</pre>
32+
* </p>
33+
* <p>
34+
* For advanced configuration, see the {@link RedisClient.Builder} class.
35+
* </p>
36+
*/
1337
public class RedisClient extends UnifiedJedis {
1438

1539
public RedisClient() {
@@ -56,7 +80,7 @@ private RedisClient(CommandExecutor commandExecutor, ConnectionProvider connecti
5680
* Obtain an instance via {@link #builder()}.
5781
* </p>
5882
*/
59-
static public class Builder extends StandaloneClientBuilder<RedisClient> {
83+
public static class Builder extends StandaloneClientBuilder<RedisClient> {
6084

6185
@Override
6286
protected RedisClient createClient() {

src/main/java/redis/clients/jedis/RedisClusterClient.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,32 @@
1313
import redis.clients.jedis.providers.ConnectionProvider;
1414
import redis.clients.jedis.util.JedisClusterCRC16;
1515

16+
/**
17+
* RedisClusterClient provides a high-level, unified interface for interacting with a Redis Cluster.
18+
* <p>
19+
* This class is intended as a modern replacement for the deprecated {@code JedisCluster} class.
20+
* It supports all cluster operations and is designed to work seamlessly with the {@link UnifiedJedis}
21+
* API, allowing for consistent usage patterns across standalone, sentinel, and cluster deployments.
22+
* <p>
23+
* <b>Usage:</b>
24+
* <pre>{@code
25+
* Set<HostAndPort> clusterNodes = new HashSet<>();
26+
* clusterNodes.add(new HostAndPort("127.0.0.1", 7000));
27+
* RedisClusterClient client = new RedisClusterClient(clusterNodes);
28+
* client.set("key", "value");
29+
* String value = client.get("key");
30+
* }</pre>
31+
* <p>
32+
* <b>Migration:</b>
33+
* Users of {@code JedisCluster} are encouraged to migrate to this class for improved API consistency,
34+
* better resource management, and enhanced support for future Redis features.
35+
* <p>
36+
* <b>Thread-safety:</b>
37+
* This client is thread-safe and can be shared across multiple threads.
38+
* <p>
39+
* <b>Configuration:</b>
40+
* Various constructors allow for flexible configuration, including authentication and custom timeouts.
41+
*/
1642
public class RedisClusterClient extends UnifiedJedis {
1743

1844
public static final String INIT_NO_ERROR_PROPERTY = "jedis.cluster.initNoError";

src/main/java/redis/clients/jedis/RedisSentinelClient.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,32 @@
77
import redis.clients.jedis.providers.ConnectionProvider;
88
import redis.clients.jedis.providers.SentineledConnectionProvider;
99

10+
/**
11+
* A high-level client for interacting with Redis Sentinel-managed Redis deployments.
12+
* <p>
13+
* {@code RedisSentinelClient} provides robust support for automatic master failover,
14+
* connection management, and command execution in environments where Redis Sentinel
15+
* is used to monitor and manage Redis servers.
16+
* </p>
17+
* <p>
18+
* Usage:
19+
* <pre>
20+
* RedisSentinelClient client = RedisSentinelClient.builder()
21+
* .sentinel("localhost", 26379)
22+
* .masterName("mymaster")
23+
* .build();
24+
* </pre>
25+
* </p>
26+
* <p>
27+
* <b>Relationship to {@code JedisSentineled}:</b>
28+
* <ul>
29+
* <li>{@code RedisSentinelClient} is the recommended replacement for the deprecated {@code JedisSentineled} class.</li>
30+
* <li>It offers improved API consistency, better failover handling, and a fluent builder for configuration.</li>
31+
* <li>Use {@code RedisSentinelClient} for new codebases and when migrating from {@code JedisSentineled}.</li>
32+
* </ul>
33+
* </p>
34+
*/
1035
public class RedisSentinelClient extends UnifiedJedis {
11-
1236
private RedisSentinelClient(CommandExecutor commandExecutor,
1337
ConnectionProvider connectionProvider, CommandObjects commandObjects,
1438
RedisProtocol redisProtocol, Cache cache) {
@@ -21,7 +45,7 @@ private RedisSentinelClient(CommandExecutor commandExecutor,
2145
* Obtain an instance via {@link #builder()}.
2246
* </p>
2347
*/
24-
static public class Builder extends SentinelClientBuilder<RedisSentinelClient> {
48+
public static class Builder extends SentinelClientBuilder<RedisSentinelClient> {
2549

2650
@Override
2751
protected RedisSentinelClient createClient() {

0 commit comments

Comments
 (0)