Skip to content

Commit bf2e2e4

Browse files
committed
Update docs
1 parent ac2a761 commit bf2e2e4

File tree

4 files changed

+25
-19
lines changed

4 files changed

+25
-19
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ Next, you'll need to connect to Redis. Consider installing a redis server with d
6666
docker run -p 6379:6379 -it redis:latest
6767
```
6868

69-
For many applications, it's best to use a connection pool. You can instantiate a JedisPooled like so:
69+
You can instantiate a RedisClient like so:
7070

7171
```java
72-
JedisPooled jedis = new JedisPooled("localhost", 6379);
72+
RedisClient jedis = RedisClient.builder().hostAndPort("localhost", 6379).build();
7373
```
7474

7575
Now you can send commands:
@@ -81,16 +81,16 @@ jedis.sadd("planets", "Venus");
8181
## Connecting to a Redis cluster
8282

8383
Jedis lets you connect to Redis Clusters, supporting the [Redis Cluster Specification](https://redis.io/topics/cluster-spec).
84-
To do this, you'll need to connect using `JedisCluster`. See the example below:
84+
To do this, you'll need to connect using `RedisClusterClient`. See the example below:
8585

8686
```java
8787
Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
8888
jedisClusterNodes.add(new HostAndPort("127.0.0.1", 7379));
8989
jedisClusterNodes.add(new HostAndPort("127.0.0.1", 7380));
90-
JedisCluster jedis = new JedisCluster(jedisClusterNodes);
90+
RedisClusterClient jedis = RedisClusterClient.builder().nodes(jedisClusterNodes).build();
9191
```
9292

93-
Now you can use the `JedisCluster` instance and send commands like you would with a standard pooled connection:
93+
Now you can use the `RedisClusterClient` instance and send commands like you would with a standard pooled connection:
9494

9595
```java
9696
jedis.sadd("planets", "Mars");

docs/advanced-usage.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,16 +255,16 @@ public class DockerNATMapper implements HostAndPortMapper {
255255
}
256256
```
257257

258-
Then, instantiate this class and pass it to the JedisCluster constructor:
258+
Then, instantiate this class and pass it to the RedisClusterClient builder:
259259

260260
```java
261261
Map<HostAndPort, HostAndPort> nodeMapping = new HashMap<>();
262-
nodeMapping.put(new HostAndPort("172.18.0.2", 6379), new HostAndPort("my-redis.example.com", 7001));
262+
nodeMapping.put(new HostAndPort("172.18.0.2", 6379), new HostAndPort("my-redis.example.com", 7001));
263263
nodeMapping.put(new HostAndPort("172.18.0.3", 6379), new HostAndPort("my-redis.example.com", 7002));
264264
nodeMapping.put(new HostAndPort("172.18.0.4", 6379), new HostAndPort("my-redis.example.com", 7002));
265265

266266
Set<HostAndPort> initialNodes = new HashSet<>();
267-
// seed node
267+
// seed node
268268
initialNodes.add(new HostAndPort("my-redis.example.com", 7001));
269269

270270
HostAndPortMapper mapper = new DockerNATMapper(nodeMapping);
@@ -275,10 +275,13 @@ JedisClientConfig jedisClientConfig = DefaultJedisClientConfig.builder()
275275
.hostAndPortMapper(mapper)
276276
.build();
277277

278-
JedisCluster jedisCluster = new JedisCluster(initialNodes, jedisClientConfig);
278+
RedisClusterClient jedisCluster = RedisClusterClient.builder()
279+
.nodes(initialNodes)
280+
.clientConfig(jedisClientConfig)
281+
.build();
279282
```
280283

281-
Now, when JedisCluster discovers a node at "172.18.0.2:6379", the mapper will translate it to "localhost:7001" before attempting to connect.
284+
Now, when RedisClusterClient discovers a node at "172.18.0.2:6379", the mapper will translate it to "localhost:7001" before attempting to connect.
282285

283286
### Implementing with a Lambda Expression
284287
Since HostAndPortMapper is a functional interface (it has only one abstract method), you can also provide the implementation more concisely using a lambda expression. This is often preferred for simpler, inline mapping logic.
@@ -300,7 +303,10 @@ JedisClientConfig jedisClientConfig = DefaultJedisClientConfig.builder()
300303
.hostAndPortMapper(mapper)
301304
.build();
302305

303-
JedisCluster jedisCluster = new JedisCluster(initialNodes, jedisClientConfig);
306+
RedisClusterClient jedisCluster = RedisClusterClient.builder()
307+
.nodes(initialNodes)
308+
.clientConfig(jedisClientConfig)
309+
.build();
304310
```
305311

306312
## Miscellaneous

docs/redisearch.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ To use RediSearch features with Jedis, you'll need to use an implementation of R
44

55
## Creating the RediSearch client
66

7-
Initializing the client with JedisPooled:
7+
Initializing the client with RedisClient:
88

99
```java
10-
JedisPooled client = new JedisPooled("localhost", 6379);
10+
RedisClient client = RedisClient.builder().hostAndPort("localhost", 6379).build();
1111
```
1212

13-
Initializing the client with JedisCluster:
13+
Initializing the client with RedisClusterClient:
1414

1515
```java
1616
Set<HostAndPort> nodes = new HashSet<>();
1717
nodes.add(new HostAndPort("127.0.0.1", 7379));
1818
nodes.add(new HostAndPort("127.0.0.1", 7380));
1919

20-
JedisCluster client = new JedisCluster(nodes);
20+
RedisClusterClient client = RedisClusterClient.builder().nodes(nodes).build();
2121
```
2222

2323
## Indexing and querying

docs/redisjson.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ Let's see how this works.
99

1010
## Creating with RedisJSON client
1111

12-
First, let's create a `JedisPooled` client instance:
12+
First, let's create a `RedisClient` client instance:
1313

1414
```java
15-
JedisPooled client = new JedisPooled("localhost", 6479);
15+
RedisClient client = RedisClient.builder().hostAndPort("localhost", 6479).build();
1616
```
1717

18-
Or, a `JedisCluster` client instance:
18+
Or, a `RedisClusterClient` client instance:
1919

2020
```java
2121
Set<HostAndPort> nodes = new HashSet<>();
2222
nodes.add(new HostAndPort("127.0.0.1", 7379));
2323
nodes.add(new HostAndPort("127.0.0.1", 7380));
2424

25-
JedisCluster client = new JedisCluster(nodes);
25+
RedisClusterClient client = RedisClusterClient.builder().nodes(nodes).build();
2626
```
2727

2828
Now we can start working with JSON. For these examples, we'll be using [GSON](https://github.com/google/gson)

0 commit comments

Comments
 (0)