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 SummaryNested classes/interfaces inherited from interface org.springframework.data.redis.connection.RedisConfigurationRedisConfiguration.ClusterConfiguration, RedisConfiguration.DomainSocketConfiguration, RedisConfiguration.SentinelConfiguration, RedisConfiguration.StaticMasterReplicaConfiguration, RedisConfiguration.WithAuthentication, RedisConfiguration.WithDatabaseIndex, RedisConfiguration.WithDomainSocket, RedisConfiguration.WithHostAndPort, RedisConfiguration.WithPassword
- 
Constructor SummaryConstructorsConstructorDescriptionCreates a new, defaultRedisClusterConfiguration.RedisClusterConfiguration(Collection<String> clusterNodes) Creates a newRedisClusterConfigurationfor givenhostPortcombinations.RedisClusterConfiguration(PropertySource<?> propertySource) Deprecated.
- 
Method SummaryModifier 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.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.data.redis.connection.RedisConfigurationgetDatabaseOrElse, getPasswordOrElseMethods inherited from interface org.springframework.data.redis.connection.RedisConfiguration.WithAuthenticationsetPassword, setPassword
- 
Constructor Details- 
RedisClusterConfigurationpublic RedisClusterConfiguration()Creates a new, defaultRedisClusterConfiguration.
- 
RedisClusterConfigurationCreates a newRedisClusterConfigurationfor givenhostPortcombinations.clusterHostAndPorts[0] = 127.0.0.1:23679 clusterHostAndPorts[1] = 127.0.0.1:23680 ... - Parameters:
- clusterNodes- must not be null.
 
- 
RedisClusterConfigurationDeprecated.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- 
ofCreates 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
 
- 
setClusterNodesSet cluster nodes to connect to.- Parameters:
- nodes- must not be null.
 
- 
getClusterNodesDescription copied from interface:RedisConfiguration.ClusterConfigurationReturns anSetofcluster nodes.- Specified by:
- getClusterNodesin interface- RedisConfiguration.ClusterConfiguration
- Returns:
- Setof- cluster nodes. Never null.
 
- 
addClusterNodeAdd 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.
 
- 
setMaxRedirectspublic void setMaxRedirects(int maxRedirects) - Parameters:
- maxRedirects- the max number of redirects to follow.
 
- 
getMaxRedirects- Specified by:
- getMaxRedirectsin interface- RedisConfiguration.ClusterConfiguration
- Returns:
- max number of redirects to follow or null if not set.
 
- 
setUsernameDescription copied from interface:RedisConfiguration.WithAuthenticationCreate and set a username with the givenString. Requires Redis 6 or newer.- Specified by:
- setUsernamein interface- RedisConfiguration.WithAuthentication
- Parameters:
- username- the username.
 
- 
getUsernameDescription copied from interface:RedisConfiguration.WithAuthenticationGet the username to use when connecting.- Specified by:
- getUsernamein interface- RedisConfiguration.WithAuthentication
- Returns:
- null if none set.
 
- 
setPasswordDescription copied from interface:RedisConfiguration.WithAuthenticationCreate and set aRedisPasswordfor givenString.- Specified by:
- setPasswordin interface- RedisConfiguration.WithAuthentication
- Parameters:
- password- must not be null use- RedisPassword.none()instead.
 
- 
getPasswordDescription copied from interface:RedisConfiguration.WithAuthenticationGet the RedisPassword to use when connecting.- Specified by:
- getPasswordin interface- RedisConfiguration.WithAuthentication
- Returns:
- RedisPassword.none()if none set.
 
- 
equals
- 
hashCodepublic int hashCode()
 
- 
RedisSentinelConfiguration.of(PropertySource)instead.