unable to set client connection to lettuceconnectionfactory to use in spring data

294 views
Skip to first unread message

Baiju Padmanabhan

unread,
Feb 12, 2018, 12:05:04 PM2/12/18
to lettuce-redis-client-users
Hi,

I am new to redis and lettuce, I am trying to use elasticache cluster and using lettuce. I am not seeing any method which sets cluster client to pass the client connection. Could you please help.

RedisURI redisUri = RedisURI.Builder.redis(clusterEndPoint, port)
.withSsl(ssl).withPassword(oassOhrase).build();


 RedisClusterClient redisClusterClient = RedisClusterClient.create(redisUri); 
 RedisAdvancedClusterConnection<String, String> connection = redisClusterClient.connectCluster();

How to set this to connectionfactory which can be used in spring data?. Could you please help?..

Thanks,
Baiju

Mark Paluch

unread,
Feb 14, 2018, 9:27:20 AM2/14/18
to lettuce-redis-client-users
That's not the right forum for Spring Data questions. Check out the Spring Data Redis docs: https://docs.spring.io/spring-data/redis/docs/current/reference/html/#cluster

rsathis...@gmail.com

unread,
Jun 12, 2020, 11:14:48 AM6/12/20
to lettuce-redis-client-users
Extends org.springframework.data.redis.connection.lettuce.DefaultLettucePool
public CustomLettucePool(String hostName, int port, String password, boolean ssl) {
this.redisHostName = hostName;
this.redisPort = port;
this.redisPassword = password;
this.redisUseSsl = ssl;
}

@Override
public RedisClient getClient() {
RedisURI.Builder redisUriBuilder = RedisURI.Builder.redis(redisHostName, redisPort);
if (redisUseSsl) {
redisUriBuilder.withSsl(redisUseSsl);
}
redisUriBuilder.withPassword(redisPassword);
RedisClient client = RedisClient.create(redisUriBuilder.build());
return client;
}

@Bean
public LettuceConnectionFactory lettuceConnectionFactory() {
CustomLettucePool lettucePool = new CustomLettucePool(redisHostName, redisPort, redisPassword, redisUseSsl);
lettucePool.setPoolConfig(poolConfig());
RedisClient client = lettucePool.getClient();
client.setOptions(clientOptions());
LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(lettucePool);
connectionFactory.setValidateConnection(true);
connectionFactory.afterPropertiesSet();
return connectionFactory;
}
Reply all
Reply to author
Forward
0 new messages