use of io.lettuce.core.cluster.ClusterClientOptions in project lettuce-core by lettuce-io.
the class ConnectToRedisClusterWithTopologyRefreshing method main.
public static void main(String[] args) {
// Syntax: redis://[password@]host[:port]
RedisClusterClient redisClient = RedisClusterClient.create("redis://password@localhost:7379");
ClusterTopologyRefreshOptions clusterTopologyRefreshOptions = //
ClusterTopologyRefreshOptions.builder().enablePeriodicRefresh(30, //
TimeUnit.MINUTES).enableAllAdaptiveRefreshTriggers().build();
ClusterClientOptions clusterClientOptions = //
ClusterClientOptions.builder().topologyRefreshOptions(//
clusterTopologyRefreshOptions).build();
redisClient.setOptions(clusterClientOptions);
StatefulRedisClusterConnection<String, String> connection = redisClient.connect();
System.out.println("Connected to Redis");
connection.close();
redisClient.shutdown();
}
Aggregations