Class RedisClusterConfiguration
java.lang.Object
org.springframework.data.redis.connection.RedisClusterConfiguration
- All Implemented Interfaces:
 RedisConfiguration,RedisConfiguration.ClusterConfiguration,RedisConfiguration.WithAuthentication,RedisConfiguration.WithPassword
public class RedisClusterConfiguration
extends Object
implements RedisConfiguration, RedisConfiguration.ClusterConfiguration
Configuration class used to set up a 
RedisConnection via RedisConnectionFactory for connecting to
 Redis Cluster. Useful when setting up a highly available Redis
 environment.- Since:
 - 1.7
 - Author:
 - Christoph Strobl, Mark Paluch, John Blum
 
- 
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.data.redis.connection.RedisConfiguration
RedisConfiguration.ClusterConfiguration, RedisConfiguration.DomainSocketConfiguration, RedisConfiguration.SentinelConfiguration, RedisConfiguration.StaticMasterReplicaConfiguration, RedisConfiguration.WithAuthentication, RedisConfiguration.WithDatabaseIndex, RedisConfiguration.WithDomainSocket, RedisConfiguration.WithHostAndPort, RedisConfiguration.WithPassword - 
Constructor Summary
ConstructorsConstructorDescriptionCreates a new, defaultRedisClusterConfiguration.RedisClusterConfiguration(Collection<String> clusterNodes) Creates a newRedisClusterConfigurationfor givenhostPortcombinations.RedisClusterConfiguration(PropertySource<?> propertySource) Deprecated. - 
Method Summary
Modifier and TypeMethodDescriptionvoidaddClusterNode(RedisNode node) Add a cluster node to configuration.clusterNode(String host, Integer port) clusterNode(RedisNode node) booleanReturns anSetofcluster nodes.Get the RedisPassword to use when connecting.Get the username to use when connecting.inthashCode()static RedisClusterConfigurationof(PropertySource<?> propertySource) Creates a newRedisClusterConfigurationlooking up configuration values from the givenPropertySource.voidsetClusterNodes(Iterable<RedisNode> nodes) Set cluster nodes to connect to.voidsetMaxRedirects(int maxRedirects) voidsetPassword(RedisPassword password) Create and set aRedisPasswordfor givenString.voidsetUsername(String username) Create and set a username with the givenString.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.data.redis.connection.RedisConfiguration
getDatabaseOrElse, getPasswordOrElseMethods inherited from interface org.springframework.data.redis.connection.RedisConfiguration.WithAuthentication
setPassword, setPassword 
- 
Constructor Details
- 
RedisClusterConfiguration
public RedisClusterConfiguration()Creates a new, defaultRedisClusterConfiguration. - 
RedisClusterConfiguration
Creates a newRedisClusterConfigurationfor givenhostPortcombinations.clusterHostAndPorts[0] = 127.0.0.1:23679 clusterHostAndPorts[1] = 127.0.0.1:23680 ...
- Parameters:
 clusterNodes- must not be null.
 - 
RedisClusterConfiguration
Deprecated.since 3.3, useRedisSentinelConfiguration.of(PropertySource)instead. This constructor will be made private in the next major release.Creates a newRedisClusterConfigurationlooking up configuration values from the givenPropertySource.spring.redis.cluster.nodes=127.0.0.1:23679,127.0.0.1:23680,127.0.0.1:23681 spring.redis.cluster.max-redirects=3
- Parameters:
 propertySource- must not be null.
 
 - 
 - 
Method Details
- 
of
Creates a newRedisClusterConfigurationlooking up configuration values from the givenPropertySource.spring.redis.cluster.nodes=127.0.0.1:23679,127.0.0.1:23680,127.0.0.1:23681 spring.redis.cluster.max-redirects=3
- Parameters:
 propertySource- must not be null.- Returns:
 - a new 
RedisClusterConfigurationconfigured from the givenPropertySource. - Since:
 - 3.3
 
 - 
setClusterNodes
Set cluster nodes to connect to.- Parameters:
 nodes- must not be null.
 - 
getClusterNodes
Description copied from interface:RedisConfiguration.ClusterConfigurationReturns anSetofcluster nodes.- Specified by:
 getClusterNodesin interfaceRedisConfiguration.ClusterConfiguration- Returns:
 Setofcluster nodes. Never null.
 - 
addClusterNode
Add a cluster node to configuration.- Parameters:
 node- must not be null.
 - 
clusterNode
- Parameters:
 host- Redis cluster node host name or ip address.port- Redis cluster node port.- Returns:
 - this.
 
 - 
clusterNode
- Returns:
 - this.
 
 - 
setMaxRedirects
public void setMaxRedirects(int maxRedirects) - Parameters:
 maxRedirects- the max number of redirects to follow.
 - 
getMaxRedirects
- Specified by:
 getMaxRedirectsin interfaceRedisConfiguration.ClusterConfiguration- Returns:
 - max number of redirects to follow or null if not set.
 
 - 
setUsername
Description copied from interface:RedisConfiguration.WithAuthenticationCreate and set a username with the givenString. Requires Redis 6 or newer.- Specified by:
 setUsernamein interfaceRedisConfiguration.WithAuthentication- Parameters:
 username- the username.
 - 
getUsername
Description copied from interface:RedisConfiguration.WithAuthenticationGet the username to use when connecting.- Specified by:
 getUsernamein interfaceRedisConfiguration.WithAuthentication- Returns:
 - null if none set.
 
 - 
setPassword
Description copied from interface:RedisConfiguration.WithAuthenticationCreate and set aRedisPasswordfor givenString.- Specified by:
 setPasswordin interfaceRedisConfiguration.WithAuthentication- Parameters:
 password- must not be null useRedisPassword.none()instead.
 - 
getPassword
Description copied from interface:RedisConfiguration.WithAuthenticationGet the RedisPassword to use when connecting.- Specified by:
 getPasswordin interfaceRedisConfiguration.WithAuthentication- Returns:
 RedisPassword.none()if none set.
 - 
equals
 - 
hashCode
public int hashCode() 
 - 
 
RedisSentinelConfiguration.of(PropertySource)instead.