64
64
* a {@link Pool} to pool dedicated connections. If shareNativeConnection is true, the pool will be used to select a
65
65
* connection for blocking and tx operations only, which should not share a connection. If native connection sharing is
66
66
* disabled, the selected connection will be used for all operations.
67
- *
67
+ *
68
68
* @author Costin Leau
69
69
* @author Jennifer Hickey
70
70
* @author Thomas Darimont
@@ -97,6 +97,7 @@ public class LettuceConnectionFactory implements InitializingBean, DisposableBea
97
97
private RedisClusterConfiguration clusterConfiguration ;
98
98
private ClusterCommandExecutor clusterCommandExecutor ;
99
99
private ClientResources clientResources ;
100
+ private boolean useSsl ;
100
101
101
102
/**
102
103
* Constructs a new <code>LettuceConnectionFactory</code> instance with default settings.
@@ -124,7 +125,7 @@ public LettuceConnectionFactory(RedisSentinelConfiguration sentinelConfiguration
124
125
/**
125
126
* Constructs a new {@link LettuceConnectionFactory} instance using the given {@link RedisClusterConfiguration}
126
127
* applied to create a {@link RedisClusterClient}.
127
- *
128
+ *
128
129
* @param clusterConfig
129
130
* @since 1.7
130
131
*/
@@ -256,7 +257,7 @@ public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
256
257
257
258
/**
258
259
* Returns the current host.
259
- *
260
+ *
260
261
* @return the host
261
262
*/
262
263
public String getHostName () {
@@ -265,7 +266,7 @@ public String getHostName() {
265
266
266
267
/**
267
268
* Sets the host.
268
- *
269
+ *
269
270
* @param host the host to set
270
271
*/
271
272
public void setHostName (String host ) {
@@ -274,7 +275,7 @@ public void setHostName(String host) {
274
275
275
276
/**
276
277
* Returns the current port.
277
- *
278
+ *
278
279
* @return the port
279
280
*/
280
281
public int getPort () {
@@ -283,7 +284,7 @@ public int getPort() {
283
284
284
285
/**
285
286
* Sets the port.
286
- *
287
+ *
287
288
* @param port the port to set
288
289
*/
289
290
public void setPort (int port ) {
@@ -292,7 +293,7 @@ public void setPort(int port) {
292
293
293
294
/**
294
295
* Returns the connection timeout (in milliseconds).
295
- *
296
+ *
296
297
* @return connection timeout
297
298
*/
298
299
public long getTimeout () {
@@ -301,16 +302,23 @@ public long getTimeout() {
301
302
302
303
/**
303
304
* Sets the connection timeout (in milliseconds).
304
- *
305
+ *
305
306
* @param timeout connection timeout
306
307
*/
307
308
public void setTimeout (long timeout ) {
308
309
this .timeout = timeout ;
309
310
}
310
311
312
+ /**
313
+ * Sets to use SSL connection
314
+ */
315
+ public void setUseSsl (boolean useSsl ){
316
+ this .useSsl = useSsl ;
317
+ }
318
+
311
319
/**
312
320
* Indicates if validation of the native Lettuce connection is enabled
313
- *
321
+ *
314
322
* @return connection validation enabled
315
323
*/
316
324
public boolean getValidateConnection () {
@@ -327,7 +335,7 @@ public boolean getValidateConnection() {
327
335
* Setting this to true will result in a round-trip call to the server on each new connection, so this setting should
328
336
* only be used if connection sharing is enabled and there is code that is actively closing the native Lettuce
329
337
* connection.
330
- *
338
+ *
331
339
* @param validateConnection enable connection validation
332
340
*/
333
341
public void setValidateConnection (boolean validateConnection ) {
@@ -336,7 +344,7 @@ public void setValidateConnection(boolean validateConnection) {
336
344
337
345
/**
338
346
* Indicates if multiple {@link LettuceConnection}s should share a single native connection.
339
- *
347
+ *
340
348
* @return native connection shared
341
349
*/
342
350
public boolean getShareNativeConnection () {
@@ -346,7 +354,7 @@ public boolean getShareNativeConnection() {
346
354
/**
347
355
* Enables multiple {@link LettuceConnection}s to share a single native connection. If set to false, every operation
348
356
* on {@link LettuceConnection} will open and close a socket.
349
- *
357
+ *
350
358
* @param shareNativeConnection enable connection sharing
351
359
*/
352
360
public void setShareNativeConnection (boolean shareNativeConnection ) {
@@ -355,7 +363,7 @@ public void setShareNativeConnection(boolean shareNativeConnection) {
355
363
356
364
/**
357
365
* Returns the index of the database.
358
- *
366
+ *
359
367
* @return Returns the database index
360
368
*/
361
369
public int getDatabase () {
@@ -364,7 +372,7 @@ public int getDatabase() {
364
372
365
373
/**
366
374
* Sets the index of the database used by this connection factory. Default is 0.
367
- *
375
+ *
368
376
* @param index database index
369
377
*/
370
378
public void setDatabase (int index ) {
@@ -374,7 +382,7 @@ public void setDatabase(int index) {
374
382
375
383
/**
376
384
* Returns the password used for authenticating with the Redis server.
377
- *
385
+ *
378
386
* @return password for authentication
379
387
*/
380
388
public String getPassword () {
@@ -383,7 +391,7 @@ public String getPassword() {
383
391
384
392
/**
385
393
* Sets the password used for authenticating with the Redis server.
386
- *
394
+ *
387
395
* @param password the password to set
388
396
*/
389
397
public void setPassword (String password ) {
@@ -392,7 +400,7 @@ public void setPassword(String password) {
392
400
393
401
/**
394
402
* Returns the shutdown timeout for shutting down the RedisClient (in milliseconds).
395
- *
403
+ *
396
404
* @return shutdown timeout
397
405
* @since 1.6
398
406
*/
@@ -402,7 +410,7 @@ public long getShutdownTimeout() {
402
410
403
411
/**
404
412
* Sets the shutdown timeout for shutting down the RedisClient (in milliseconds).
405
- *
413
+ *
406
414
* @param shutdownTimeout the shutdown timeout
407
415
* @since 1.6
408
416
*/
@@ -412,7 +420,7 @@ public void setShutdownTimeout(long shutdownTimeout) {
412
420
413
421
/**
414
422
* Get the {@link ClientResources} to reuse infrastructure.
415
- *
423
+ *
416
424
* @return {@literal null} if not set.
417
425
* @since 1.7
418
426
*/
@@ -423,7 +431,7 @@ public ClientResources getClientResources() {
423
431
/**
424
432
* Sets the {@link ClientResources} to reuse the client infrastructure. <br />
425
433
* Set to {@literal null} to not share resources.
426
- *
434
+ *
427
435
* @param clientResources can be {@literal null}.
428
436
* @since 1.7
429
437
*/
@@ -435,7 +443,7 @@ public void setClientResources(ClientResources clientResources) {
435
443
* Specifies if pipelined results should be converted to the expected data type. If false, results of
436
444
* {@link LettuceConnection#closePipeline()} and {LettuceConnection#exec()} will be of the type returned by the
437
445
* Lettuce driver
438
- *
446
+ *
439
447
* @return Whether or not to convert pipeline and tx results
440
448
*/
441
449
public boolean getConvertPipelineAndTxResults () {
@@ -446,7 +454,7 @@ public boolean getConvertPipelineAndTxResults() {
446
454
* Specifies if pipelined and transaction results should be converted to the expected data type. If false, results of
447
455
* {@link LettuceConnection#closePipeline()} and {LettuceConnection#exec()} will be of the type returned by the
448
456
* Lettuce driver
449
- *
457
+ *
450
458
* @param convertPipelineAndTxResults Whether or not to convert pipeline and tx results
451
459
*/
452
460
public void setConvertPipelineAndTxResults (boolean convertPipelineAndTxResults ) {
@@ -536,6 +544,7 @@ private AbstractRedisClient createRedisClient() {
536
544
if (password != null ) {
537
545
builder .withPassword (password );
538
546
}
547
+ builder .withSsl (useSsl );
539
548
builder .withTimeout (timeout , TimeUnit .MILLISECONDS );
540
549
if (clientResources != null ) {
541
550
return RedisClient .create (clientResources , builder .build ());
0 commit comments