6464 * a {@link Pool} to pool dedicated connections. If shareNativeConnection is true, the pool will be used to select a
6565 * connection for blocking and tx operations only, which should not share a connection. If native connection sharing is
6666 * disabled, the selected connection will be used for all operations.
67- *
67+ *
6868 * @author Costin Leau
6969 * @author Jennifer Hickey
7070 * @author Thomas Darimont
@@ -97,6 +97,7 @@ public class LettuceConnectionFactory implements InitializingBean, DisposableBea
9797private RedisClusterConfiguration clusterConfiguration ;
9898private ClusterCommandExecutor clusterCommandExecutor ;
9999private ClientResources clientResources ;
100+ private boolean useSsl ;
100101
101102/**
102103 * Constructs a new <code>LettuceConnectionFactory</code> instance with default settings.
@@ -124,7 +125,7 @@ public LettuceConnectionFactory(RedisSentinelConfiguration sentinelConfiguration
124125/**
125126 * Constructs a new {@link LettuceConnectionFactory} instance using the given {@link RedisClusterConfiguration}
126127 * applied to create a {@link RedisClusterClient}.
127- *
128+ *
128129 * @param clusterConfig
129130 * @since 1.7
130131 */
@@ -256,7 +257,7 @@ public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
256257
257258/**
258259 * Returns the current host.
259- *
260+ *
260261 * @return the host
261262 */
262263public String getHostName () {
@@ -265,7 +266,7 @@ public String getHostName() {
265266
266267/**
267268 * Sets the host.
268- *
269+ *
269270 * @param host the host to set
270271 */
271272public void setHostName (String host ) {
@@ -274,7 +275,7 @@ public void setHostName(String host) {
274275
275276/**
276277 * Returns the current port.
277- *
278+ *
278279 * @return the port
279280 */
280281public int getPort () {
@@ -283,7 +284,7 @@ public int getPort() {
283284
284285/**
285286 * Sets the port.
286- *
287+ *
287288 * @param port the port to set
288289 */
289290public void setPort (int port ) {
@@ -292,7 +293,7 @@ public void setPort(int port) {
292293
293294/**
294295 * Returns the connection timeout (in milliseconds).
295- *
296+ *
296297 * @return connection timeout
297298 */
298299public long getTimeout () {
@@ -301,16 +302,23 @@ public long getTimeout() {
301302
302303/**
303304 * Sets the connection timeout (in milliseconds).
304- *
305+ *
305306 * @param timeout connection timeout
306307 */
307308public void setTimeout (long timeout ) {
308309this .timeout = timeout ;
309310}
310311
312+ /**
313+ * Sets to use SSL connection
314+ */
315+ public void setUseSsl (boolean useSsl ){
316+ this .useSsl = useSsl ;
317+ }
318+
311319/**
312320 * Indicates if validation of the native Lettuce connection is enabled
313- *
321+ *
314322 * @return connection validation enabled
315323 */
316324public boolean getValidateConnection () {
@@ -327,7 +335,7 @@ public boolean getValidateConnection() {
327335 * Setting this to true will result in a round-trip call to the server on each new connection, so this setting should
328336 * only be used if connection sharing is enabled and there is code that is actively closing the native Lettuce
329337 * connection.
330- *
338+ *
331339 * @param validateConnection enable connection validation
332340 */
333341public void setValidateConnection (boolean validateConnection ) {
@@ -336,7 +344,7 @@ public void setValidateConnection(boolean validateConnection) {
336344
337345/**
338346 * Indicates if multiple {@link LettuceConnection}s should share a single native connection.
339- *
347+ *
340348 * @return native connection shared
341349 */
342350public boolean getShareNativeConnection () {
@@ -346,7 +354,7 @@ public boolean getShareNativeConnection() {
346354/**
347355 * Enables multiple {@link LettuceConnection}s to share a single native connection. If set to false, every operation
348356 * on {@link LettuceConnection} will open and close a socket.
349- *
357+ *
350358 * @param shareNativeConnection enable connection sharing
351359 */
352360public void setShareNativeConnection (boolean shareNativeConnection ) {
@@ -355,7 +363,7 @@ public void setShareNativeConnection(boolean shareNativeConnection) {
355363
356364/**
357365 * Returns the index of the database.
358- *
366+ *
359367 * @return Returns the database index
360368 */
361369public int getDatabase () {
@@ -364,7 +372,7 @@ public int getDatabase() {
364372
365373/**
366374 * Sets the index of the database used by this connection factory. Default is 0.
367- *
375+ *
368376 * @param index database index
369377 */
370378public void setDatabase (int index ) {
@@ -374,7 +382,7 @@ public void setDatabase(int index) {
374382
375383/**
376384 * Returns the password used for authenticating with the Redis server.
377- *
385+ *
378386 * @return password for authentication
379387 */
380388public String getPassword () {
@@ -383,7 +391,7 @@ public String getPassword() {
383391
384392/**
385393 * Sets the password used for authenticating with the Redis server.
386- *
394+ *
387395 * @param password the password to set
388396 */
389397public void setPassword (String password ) {
@@ -392,7 +400,7 @@ public void setPassword(String password) {
392400
393401/**
394402 * Returns the shutdown timeout for shutting down the RedisClient (in milliseconds).
395- *
403+ *
396404 * @return shutdown timeout
397405 * @since 1.6
398406 */
@@ -402,7 +410,7 @@ public long getShutdownTimeout() {
402410
403411/**
404412 * Sets the shutdown timeout for shutting down the RedisClient (in milliseconds).
405- *
413+ *
406414 * @param shutdownTimeout the shutdown timeout
407415 * @since 1.6
408416 */
@@ -412,7 +420,7 @@ public void setShutdownTimeout(long shutdownTimeout) {
412420
413421/**
414422 * Get the {@link ClientResources} to reuse infrastructure.
415- *
423+ *
416424 * @return {@literal null} if not set.
417425 * @since 1.7
418426 */
@@ -423,7 +431,7 @@ public ClientResources getClientResources() {
423431/**
424432 * Sets the {@link ClientResources} to reuse the client infrastructure. <br />
425433 * Set to {@literal null} to not share resources.
426- *
434+ *
427435 * @param clientResources can be {@literal null}.
428436 * @since 1.7
429437 */
@@ -435,7 +443,7 @@ public void setClientResources(ClientResources clientResources) {
435443 * Specifies if pipelined results should be converted to the expected data type. If false, results of
436444 * {@link LettuceConnection#closePipeline()} and {LettuceConnection#exec()} will be of the type returned by the
437445 * Lettuce driver
438- *
446+ *
439447 * @return Whether or not to convert pipeline and tx results
440448 */
441449public boolean getConvertPipelineAndTxResults () {
@@ -446,7 +454,7 @@ public boolean getConvertPipelineAndTxResults() {
446454 * Specifies if pipelined and transaction results should be converted to the expected data type. If false, results of
447455 * {@link LettuceConnection#closePipeline()} and {LettuceConnection#exec()} will be of the type returned by the
448456 * Lettuce driver
449- *
457+ *
450458 * @param convertPipelineAndTxResults Whether or not to convert pipeline and tx results
451459 */
452460public void setConvertPipelineAndTxResults (boolean convertPipelineAndTxResults ) {
@@ -536,6 +544,7 @@ private AbstractRedisClient createRedisClient() {
536544if (password != null ) {
537545builder .withPassword (password );
538546}
547+ builder .withSsl (useSsl );
539548builder .withTimeout (timeout , TimeUnit .MILLISECONDS );
540549if (clientResources != null ) {
541550return RedisClient .create (clientResources , builder .build ());
0 commit comments