or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

authentication.mdclient-side-caching.mdclustering.mdcommands-operations.mdconnection-management.mdcore-clients.mdexceptions.mdindex.mdmodules.mdparameters.mdpubsub.mdtransactions-pipelining.md

connection-management.mddocs/

0

# Connection Management

1

2

This document covers Jedis connection management including connection pools, factories, configuration, and lifecycle management for optimal performance and resource utilization.

3

4

## Core Connection Classes

5

6

### Connection

7

8

Low-level Redis connection handling network I/O and protocol communication.

9

10

```java { .api }

11

public class Connection implements Closeable {

12

/**

13

* Creates connection to Redis server

14

* @param host Redis server host

15

* @param port Redis server port

16

*/

17

public Connection(String host, int port);

18

19

/**

20

* Creates connection with timeout configuration

21

* @param host Redis server host

22

* @param port Redis server port

23

* @param connectionTimeout Connection timeout in milliseconds

24

* @param soTimeout Socket timeout in milliseconds

25

*/

26

public Connection(String host, int port, int connectionTimeout, int soTimeout);

27

28

/**

29

* Creates connection with client configuration

30

* @param hostAndPort Server endpoint

31

* @param clientConfig Client configuration

32

*/

33

public Connection(HostAndPort hostAndPort, JedisClientConfig clientConfig);

34

35

/**

36

* Establishes connection to Redis server

37

*/

38

public void connect();

39

40

/**

41

* Disconnects from Redis server

42

*/

43

public void disconnect();

44

45

/**

46

* Checks if connection is established

47

* @return true if connected

48

*/

49

public boolean isConnected();

50

51

/**

52

* Gets connection timeout

53

* @return Connection timeout in milliseconds

54

*/

55

public int getConnectionTimeout();

56

57

/**

58

* Gets socket timeout

59

* @return Socket timeout in milliseconds

60

*/

61

public int getSoTimeout();

62

63

/**

64

* Sends Redis command over connection

65

* @param cmd Protocol command

66

* @param args Command arguments

67

*/

68

public void sendCommand(ProtocolCommand cmd, String... args);

69

70

/**

71

* Sends Redis command with byte arguments

72

* @param cmd Protocol command

73

* @param args Binary command arguments

74

*/

75

public void sendCommand(ProtocolCommand cmd, byte[]... args);

76

77

/**

78

* Gets Redis server host

79

* @return Server host

80

*/

81

public String getHost();

82

83

/**

84

* Gets Redis server port

85

* @return Server port

86

*/

87

public int getPort();

88

89

/**

90

* Closes the connection

91

*/

92

public void close();

93

}

94

```

95

96

### HostAndPort

97

98

Represents a Redis server endpoint with host and port information.

99

100

```java { .api }

101

public class HostAndPort implements Serializable {

102

/**

103

* Creates host and port endpoint

104

* @param host Server hostname or IP address

105

* @param port Server port number

106

*/

107

public HostAndPort(String host, int port);

108

109

/**

110

* Gets the host

111

* @return Server host

112

*/

113

public String getHost();

114

115

/**

116

* Gets the port

117

* @return Server port

118

*/

119

public int getPort();

120

121

/**

122

* Parses host:port string into HostAndPort

123

* @param hostAndPortStr String in format "host:port"

124

* @return HostAndPort instance

125

*/

126

public static HostAndPort parseString(String hostAndPortStr);

127

128

/**

129

* Converts multiple host:port strings to HostAndPort set

130

* @param hostAndPortStrings Array of "host:port" strings

131

* @return Set of HostAndPort instances

132

*/

133

public static Set<HostAndPort> parseStrings(String... hostAndPortStrings);

134

135

@Override

136

public boolean equals(Object obj);

137

138

@Override

139

public int hashCode();

140

141

@Override

142

public String toString();

143

}

144

```

145

146

## Connection Pooling

147

148

### JedisPoolConfig

149

150

Configuration for Jedis connection pools, extending Apache Commons Pool configuration.

151

152

```java { .api }

153

public class JedisPoolConfig extends GenericObjectPoolConfig<Jedis> {

154

/**

155

* Creates pool configuration with default settings

156

*/

157

public JedisPoolConfig();

158

159

/**

160

* Sets maximum number of connections in pool

161

* @param maxTotal Maximum total connections

162

*/

163

public void setMaxTotal(int maxTotal);

164

165

/**

166

* Gets maximum number of connections in pool

167

* @return Maximum total connections

168

*/

169

public int getMaxTotal();

170

171

/**

172

* Sets maximum number of idle connections

173

* @param maxIdle Maximum idle connections

174

*/

175

public void setMaxIdle(int maxIdle);

176

177

/**

178

* Gets maximum number of idle connections

179

* @return Maximum idle connections

180

*/

181

public int getMaxIdle();

182

183

/**

184

* Sets minimum number of idle connections

185

* @param minIdle Minimum idle connections

186

*/

187

public void setMinIdle(int minIdle);

188

189

/**

190

* Gets minimum number of idle connections

191

* @return Minimum idle connections

192

*/

193

public int getMinIdle();

194

195

/**

196

* Sets whether to test connections when borrowing from pool

197

* @param testOnBorrow true to test connections

198

*/

199

public void setTestOnBorrow(boolean testOnBorrow);

200

201

/**

202

* Gets whether connections are tested when borrowed

203

* @return true if testing on borrow

204

*/

205

public boolean getTestOnBorrow();

206

207

/**

208

* Sets whether to test connections when returning to pool

209

* @param testOnReturn true to test connections

210

*/

211

public void setTestOnReturn(boolean testOnReturn);

212

213

/**

214

* Sets whether to test idle connections

215

* @param testWhileIdle true to test idle connections

216

*/

217

public void setTestWhileIdle(boolean testWhileIdle);

218

219

/**

220

* Sets time between eviction runs

221

* @param timeBetweenEvictionRunsMillis Time in milliseconds

222

*/

223

public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis);

224

225

/**

226

* Sets minimum idle time before eviction

227

* @param minEvictableIdleTimeMillis Time in milliseconds

228

*/

229

public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis);

230

231

/**

232

* Sets maximum wait time for connection

233

* @param maxWaitMillis Maximum wait time in milliseconds

234

*/

235

public void setMaxWaitMillis(long maxWaitMillis);

236

237

/**

238

* Sets number of tests per eviction run

239

* @param numTestsPerEvictionRun Number of tests

240

*/

241

public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun);

242

243

/**

244

* Sets action when pool is exhausted

245

* @param whenExhaustedAction Action to take (WHEN_EXHAUSTED_BLOCK, WHEN_EXHAUSTED_FAIL, WHEN_EXHAUSTED_GROW)

246

*/

247

public void setBlockWhenExhausted(boolean blockWhenExhausted);

248

249

/**

250

* Sets LIFO behavior for pool

251

* @param lifo true for LIFO, false for FIFO

252

*/

253

public void setLifo(boolean lifo);

254

}

255

```

256

257

#### Usage Example

258

259

```java

260

JedisPoolConfig poolConfig = new JedisPoolConfig();

261

262

// Connection limits

263

poolConfig.setMaxTotal(128); // Maximum connections

264

poolConfig.setMaxIdle(128); // Maximum idle connections

265

poolConfig.setMinIdle(16); // Minimum idle connections

266

267

// Connection testing

268

poolConfig.setTestOnBorrow(true); // Test before lending

269

poolConfig.setTestOnReturn(false); // Don't test on return

270

poolConfig.setTestWhileIdle(true); // Test idle connections

271

272

// Eviction policy

273

poolConfig.setMinEvictableIdleTimeMillis(60000); // 1 minute

274

poolConfig.setTimeBetweenEvictionRunsMillis(30000); // 30 seconds

275

poolConfig.setNumTestsPerEvictionRun(3);

276

277

// Blocking behavior

278

poolConfig.setBlockWhenExhausted(true); // Block when no connections available

279

poolConfig.setMaxWaitMillis(10000); // Wait up to 10 seconds

280

281

JedisPool pool = new JedisPool(poolConfig, "localhost", 6379);

282

```

283

284

### ConnectionPool

285

286

Generic connection pool for managing Connection instances.

287

288

```java { .api }

289

public class ConnectionPool implements Closeable {

290

/**

291

* Creates connection pool

292

* @param poolConfig Pool configuration

293

* @param factory Connection factory

294

*/

295

public ConnectionPool(GenericObjectPoolConfig<Connection> poolConfig,

296

ConnectionFactory factory);

297

298

/**

299

* Gets connection from pool

300

* @return Connection instance

301

*/

302

public Connection getResource();

303

304

/**

305

* Returns connection to pool

306

* @param connection Connection to return

307

*/

308

public void returnResource(Connection connection);

309

310

/**

311

* Returns broken connection to pool

312

* @param connection Broken connection

313

*/

314

public void returnBrokenResource(Connection connection);

315

316

/**

317

* Gets number of active connections

318

* @return Active connection count

319

*/

320

public int getNumActive();

321

322

/**

323

* Gets number of idle connections

324

* @return Idle connection count

325

*/

326

public int getNumIdle();

327

328

/**

329

* Closes the pool

330

*/

331

public void close();

332

333

/**

334

* Destroys the pool

335

*/

336

public void destroy();

337

}

338

```

339

340

### ConnectionFactory

341

342

Factory for creating Connection instances with specific configuration.

343

344

```java { .api }

345

public class ConnectionFactory implements PooledObjectFactory<Connection> {

346

/**

347

* Creates connection factory

348

* @param hostAndPort Server endpoint

349

* @param clientConfig Client configuration

350

*/

351

public ConnectionFactory(HostAndPort hostAndPort, JedisClientConfig clientConfig);

352

353

/**

354

* Creates a new connection instance

355

* @return PooledObject wrapping connection

356

*/

357

@Override

358

public PooledObject<Connection> makeObject();

359

360

/**

361

* Destroys a connection

362

* @param pooledConnection Connection to destroy

363

*/

364

@Override

365

public void destroyObject(PooledObject<Connection> pooledConnection);

366

367

/**

368

* Validates a connection

369

* @param pooledConnection Connection to validate

370

* @return true if connection is valid

371

*/

372

@Override

373

public boolean validateObject(PooledObject<Connection> pooledConnection);

374

375

/**

376

* Activates a connection when borrowed from pool

377

* @param pooledConnection Connection to activate

378

*/

379

@Override

380

public void activateObject(PooledObject<Connection> pooledConnection);

381

382

/**

383

* Passivates connection when returned to pool

384

* @param pooledConnection Connection to passivate

385

*/

386

@Override

387

public void passivateObject(PooledObject<Connection> pooledConnection);

388

}

389

```

390

391

## Connection Providers

392

393

### ConnectionProvider

394

395

Interface for providing Redis connections in different deployment scenarios.

396

397

```java { .api }

398

public interface ConnectionProvider extends Closeable {

399

/**

400

* Gets connection for executing commands

401

* @return Connection instance

402

*/

403

Connection getConnection();

404

405

/**

406

* Gets connection for specified command arguments

407

* @param commandArguments Command arguments that may determine routing

408

* @return Connection instance

409

*/

410

Connection getConnection(CommandArguments commandArguments);

411

412

/**

413

* Closes the connection provider

414

*/

415

void close();

416

}

417

```

418

419

### PooledConnectionProvider

420

421

Connection provider using connection pooling for single Redis instances.

422

423

```java { .api }

424

public class PooledConnectionProvider implements ConnectionProvider {

425

/**

426

* Creates pooled connection provider

427

* @param pool Connection pool

428

*/

429

public PooledConnectionProvider(Pool<Connection> pool);

430

431

/**

432

* Creates pooled connection provider from Jedis pool

433

* @param jedisPool Jedis pool

434

*/

435

public PooledConnectionProvider(JedisPool jedisPool);

436

437

/**

438

* Creates pooled connection provider with configuration

439

* @param hostAndPort Server endpoint

440

* @param clientConfig Client configuration

441

* @param poolConfig Pool configuration

442

*/

443

public PooledConnectionProvider(HostAndPort hostAndPort,

444

JedisClientConfig clientConfig,

445

GenericObjectPoolConfig<Connection> poolConfig);

446

447

@Override

448

public Connection getConnection();

449

450

@Override

451

public Connection getConnection(CommandArguments commandArguments);

452

453

/**

454

* Gets the underlying connection pool

455

* @return Connection pool

456

*/

457

public Pool<Connection> getPool();

458

459

@Override

460

public void close();

461

}

462

```

463

464

### ClusterConnectionProvider

465

466

Connection provider for Redis Cluster deployments.

467

468

```java { .api }

469

public class ClusterConnectionProvider implements ConnectionProvider {

470

/**

471

* Creates cluster connection provider

472

* @param clusterNodes Set of cluster nodes

473

* @param clientConfig Client configuration

474

*/

475

public ClusterConnectionProvider(Set<HostAndPort> clusterNodes,

476

JedisClientConfig clientConfig);

477

478

/**

479

* Creates cluster connection provider with pool configuration

480

* @param clusterNodes Set of cluster nodes

481

* @param clientConfig Client configuration

482

* @param poolConfig Pool configuration

483

*/

484

public ClusterConnectionProvider(Set<HostAndPort> clusterNodes,

485

JedisClientConfig clientConfig,

486

GenericObjectPoolConfig<Connection> poolConfig);

487

488

@Override

489

public Connection getConnection();

490

491

@Override

492

public Connection getConnection(CommandArguments commandArguments);

493

494

/**

495

* Gets connection for specific slot

496

* @param slot Cluster slot number

497

* @return Connection to node handling the slot

498

*/

499

public Connection getConnectionFromSlot(int slot);

500

501

/**

502

* Gets connection for specific node

503

* @param node Cluster node endpoint

504

* @return Connection to the specified node

505

*/

506

public Connection getConnectionFromNode(HostAndPort node);

507

508

/**

509

* Refreshes cluster topology

510

*/

511

public void renewSlotCache();

512

513

/**

514

* Gets all cluster nodes

515

* @return Map of node endpoints to connection pools

516

*/

517

public Map<String, Pool<Connection>> getNodes();

518

519

@Override

520

public void close();

521

}

522

```

523

524

### SentineledConnectionProvider

525

526

Connection provider with Redis Sentinel integration for high availability.

527

528

```java { .api }

529

public class SentineledConnectionProvider implements ConnectionProvider {

530

/**

531

* Creates sentineled connection provider

532

* @param masterName Redis master name in Sentinel configuration

533

* @param sentinels Set of Sentinel endpoints

534

* @param clientConfig Client configuration

535

* @param poolConfig Pool configuration

536

*/

537

public SentineledConnectionProvider(String masterName,

538

Set<HostAndPort> sentinels,

539

JedisClientConfig clientConfig,

540

GenericObjectPoolConfig<Connection> poolConfig);

541

542

@Override

543

public Connection getConnection();

544

545

@Override

546

public Connection getConnection(CommandArguments commandArguments);

547

548

/**

549

* Gets current master endpoint

550

* @return Current master host and port

551

*/

552

public HostAndPort getCurrentMaster();

553

554

/**

555

* Gets connection pool for current master

556

* @return Master connection pool

557

*/

558

public Pool<Connection> getMasterPool();

559

560

@Override

561

public void close();

562

}

563

```

564

565

## Connection Configuration

566

567

### JedisClientConfig

568

569

Comprehensive client configuration interface.

570

571

```java { .api }

572

public interface JedisClientConfig {

573

/**

574

* Gets connection timeout

575

* @return Connection timeout in milliseconds

576

*/

577

int getConnectionTimeoutMillis();

578

579

/**

580

* Gets socket timeout for Redis operations

581

* @return Socket timeout in milliseconds

582

*/

583

int getSoTimeoutMillis();

584

585

/**

586

* Gets blocking socket timeout for blocking operations

587

* @return Blocking socket timeout in milliseconds

588

*/

589

int getBlockingSocketTimeoutMillis();

590

591

/**

592

* Gets Redis username for authentication

593

* @return Username or null if not set

594

*/

595

String getUser();

596

597

/**

598

* Gets Redis password for authentication

599

* @return Password or null if not set

600

*/

601

String getPassword();

602

603

/**

604

* Gets Redis database number

605

* @return Database index (0-15)

606

*/

607

int getDatabase();

608

609

/**

610

* Gets client name for Redis CLIENT SETNAME

611

* @return Client name or null if not set

612

*/

613

String getClientName();

614

615

/**

616

* Checks if SSL/TLS is enabled

617

* @return true if SSL enabled

618

*/

619

boolean isSsl();

620

621

/**

622

* Gets SSL socket factory

623

* @return SSL socket factory or null if not set

624

*/

625

SSLSocketFactory getSslSocketFactory();

626

627

/**

628

* Gets SSL parameters

629

* @return SSL parameters or null if not set

630

*/

631

SSLParameters getSslParameters();

632

633

/**

634

* Gets hostname verifier for SSL

635

* @return Hostname verifier or null if not set

636

*/

637

HostnameVerifier getHostnameVerifier();

638

639

/**

640

* Gets Redis protocol version

641

* @return Redis protocol (RESP2 or RESP3)

642

*/

643

RedisProtocol getRedisProtocol();

644

645

/**

646

* Gets credentials provider

647

* @return Credentials provider or null if not set

648

*/

649

RedisCredentialsProvider getCredentialsProvider();

650

651

/**

652

* Gets socket factory

653

* @return Socket factory or null for default

654

*/

655

JedisSocketFactory getSocketFactory();

656

}

657

```

658

659

### DefaultJedisClientConfig

660

661

Default implementation of JedisClientConfig with builder pattern.

662

663

```java { .api }

664

public class DefaultJedisClientConfig implements JedisClientConfig {

665

/**

666

* Creates builder for client configuration

667

* @return Configuration builder

668

*/

669

public static Builder builder() {

670

return new Builder();

671

}

672

673

/**

674

* Creates default configuration

675

* @return Default client configuration

676

*/

677

public static JedisClientConfig create() {

678

return new DefaultJedisClientConfig();

679

}

680

681

public static class Builder {

682

/**

683

* Sets connection timeout

684

* @param connectionTimeoutMillis Timeout in milliseconds

685

* @return Builder instance

686

*/

687

public Builder connectionTimeoutMillis(int connectionTimeoutMillis);

688

689

/**

690

* Sets socket timeout

691

* @param socketTimeoutMillis Timeout in milliseconds

692

* @return Builder instance

693

*/

694

public Builder socketTimeoutMillis(int socketTimeoutMillis);

695

696

/**

697

* Sets blocking socket timeout

698

* @param blockingSocketTimeoutMillis Timeout in milliseconds

699

* @return Builder instance

700

*/

701

public Builder blockingSocketTimeoutMillis(int blockingSocketTimeoutMillis);

702

703

/**

704

* Sets Redis username

705

* @param user Username

706

* @return Builder instance

707

*/

708

public Builder user(String user);

709

710

/**

711

* Sets Redis password

712

* @param password Password

713

* @return Builder instance

714

*/

715

public Builder password(String password);

716

717

/**

718

* Sets Redis database

719

* @param database Database index

720

* @return Builder instance

721

*/

722

public Builder database(int database);

723

724

/**

725

* Sets client name

726

* @param clientName Client identifier

727

* @return Builder instance

728

*/

729

public Builder clientName(String clientName);

730

731

/**

732

* Enables SSL/TLS

733

* @param ssl true to enable SSL

734

* @return Builder instance

735

*/

736

public Builder ssl(boolean ssl);

737

738

/**

739

* Sets SSL socket factory

740

* @param sslSocketFactory SSL socket factory

741

* @return Builder instance

742

*/

743

public Builder sslSocketFactory(SSLSocketFactory sslSocketFactory);

744

745

/**

746

* Sets SSL parameters

747

* @param sslParameters SSL parameters

748

* @return Builder instance

749

*/

750

public Builder sslParameters(SSLParameters sslParameters);

751

752

/**

753

* Sets hostname verifier

754

* @param hostnameVerifier Hostname verifier

755

* @return Builder instance

756

*/

757

public Builder hostnameVerifier(HostnameVerifier hostnameVerifier);

758

759

/**

760

* Sets Redis protocol version

761

* @param protocol Protocol version

762

* @return Builder instance

763

*/

764

public Builder protocol(RedisProtocol protocol);

765

766

/**

767

* Sets credentials provider

768

* @param credentialsProvider Credentials provider

769

* @return Builder instance

770

*/

771

public Builder credentialsProvider(RedisCredentialsProvider credentialsProvider);

772

773

/**

774

* Sets socket factory

775

* @param socketFactory Socket factory

776

* @return Builder instance

777

*/

778

public Builder socketFactory(JedisSocketFactory socketFactory);

779

780

/**

781

* Builds the configuration

782

* @return Client configuration instance

783

*/

784

public DefaultJedisClientConfig build();

785

}

786

}

787

```

788

789

## Socket Factories

790

791

### JedisSocketFactory

792

793

Interface for custom socket creation.

794

795

```java { .api }

796

public interface JedisSocketFactory {

797

/**

798

* Creates socket for Redis connection

799

* @param host Redis server host

800

* @param port Redis server port

801

* @return Socket instance

802

* @throws IOException If socket creation fails

803

*/

804

Socket createSocket(String host, int port) throws IOException;

805

806

/**

807

* Updates socket after creation

808

* @param socket Socket to update

809

* @throws IOException If socket update fails

810

*/

811

void updateSocket(Socket socket) throws IOException;

812

}

813

```

814

815

### DefaultJedisSocketFactory

816

817

Default socket factory implementation.

818

819

```java { .api }

820

public class DefaultJedisSocketFactory implements JedisSocketFactory {

821

/**

822

* Creates default socket factory

823

*/

824

public DefaultJedisSocketFactory();

825

826

/**

827

* Creates socket factory with SSL configuration

828

* @param sslSocketFactory SSL socket factory

829

* @param sslParameters SSL parameters

830

* @param hostnameVerifier Hostname verifier

831

*/

832

public DefaultJedisSocketFactory(SSLSocketFactory sslSocketFactory,

833

SSLParameters sslParameters,

834

HostnameVerifier hostnameVerifier);

835

836

@Override

837

public Socket createSocket(String host, int port) throws IOException;

838

839

@Override

840

public void updateSocket(Socket socket) throws IOException;

841

}

842

```

843

844

## Connection Utilities

845

846

### HostAndPortMapper

847

848

Interface for mapping server endpoints, useful for network address translation.

849

850

```java { .api }

851

public interface HostAndPortMapper {

852

/**

853

* Maps a host and port to different endpoint

854

* @param hostAndPort Original endpoint

855

* @return Mapped endpoint

856

*/

857

HostAndPort getHostAndPort(HostAndPort hostAndPort);

858

}

859

```

860

861

### Usage Examples

862

863

#### Basic Pool Configuration

864

865

```java

866

// Create optimized pool configuration

867

JedisPoolConfig poolConfig = new JedisPoolConfig();

868

869

// Size configuration

870

poolConfig.setMaxTotal(200); // Max connections

871

poolConfig.setMaxIdle(50); // Max idle connections

872

poolConfig.setMinIdle(10); // Min idle connections

873

874

// Health checking

875

poolConfig.setTestOnBorrow(true); // Test before use

876

poolConfig.setTestWhileIdle(true); // Test idle connections

877

poolConfig.setMinEvictableIdleTimeMillis(60000); // Evict after 1 minute idle

878

879

// Timeout configuration

880

poolConfig.setMaxWaitMillis(5000); // Wait up to 5 seconds for connection

881

882

// Client configuration

883

JedisClientConfig clientConfig = DefaultJedisClientConfig.builder()

884

.connectionTimeoutMillis(2000)

885

.socketTimeoutMillis(2000)

886

.user("myuser")

887

.password("mypassword")

888

.database(0)

889

.clientName("myapp")

890

.build();

891

892

// Create pool

893

JedisPool pool = new JedisPool(poolConfig, "localhost", 6379, clientConfig);

894

```

895

896

#### SSL Configuration

897

898

```java

899

// SSL configuration

900

JedisClientConfig sslConfig = DefaultJedisClientConfig.builder()

901

.ssl(true)

902

.sslSocketFactory(createTrustedSslSocketFactory())

903

.hostnameVerifier((hostname, session) -> hostname.equals("redis.example.com"))

904

.build();

905

906

JedisPool sslPool = new JedisPool(poolConfig, "redis.example.com", 6380, sslConfig);

907

```

908

909

#### Connection Provider Pattern

910

911

```java

912

// Single instance with pooling

913

ConnectionProvider provider = new PooledConnectionProvider(

914

new HostAndPort("localhost", 6379),

915

clientConfig,

916

poolConfig

917

);

918

919

// Use with UnifiedJedis

920

UnifiedJedis jedis = new UnifiedJedis(provider);

921

922

// Cluster provider

923

Set<HostAndPort> clusterNodes = Set.of(

924

new HostAndPort("node1", 7000),

925

new HostAndPort("node2", 7001),

926

new HostAndPort("node3", 7002)

927

);

928

929

ConnectionProvider clusterProvider = new ClusterConnectionProvider(

930

clusterNodes, clientConfig, poolConfig

931

);

932

933

UnifiedJedis clusterJedis = new UnifiedJedis(clusterProvider);

934

```