Search in sources :

Example 1 with ClusterClientOptions

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();
}
Also used : RedisClusterClient(io.lettuce.core.cluster.RedisClusterClient) ClusterTopologyRefreshOptions(io.lettuce.core.cluster.ClusterTopologyRefreshOptions) ClusterClientOptions(io.lettuce.core.cluster.ClusterClientOptions)

Aggregations

ClusterClientOptions (io.lettuce.core.cluster.ClusterClientOptions)1 ClusterTopologyRefreshOptions (io.lettuce.core.cluster.ClusterTopologyRefreshOptions)1 RedisClusterClient (io.lettuce.core.cluster.RedisClusterClient)1