public class RedisClusterConfiguration extends Object implements RedisConfiguration, RedisConfiguration.ClusterConfiguration
RedisConnection
via RedisConnectionFactory
using connecting
to Redis Cluster. Useful when setting up a high availability Redis
environment.RedisConfiguration.ClusterConfiguration, RedisConfiguration.DomainSocketConfiguration, RedisConfiguration.SentinelConfiguration, RedisConfiguration.StaticMasterReplicaConfiguration, RedisConfiguration.WithAuthentication, RedisConfiguration.WithDatabaseIndex, RedisConfiguration.WithDomainSocket, RedisConfiguration.WithHostAndPort, RedisConfiguration.WithPassword
Constructor and Description |
---|
RedisClusterConfiguration()
Creates new
RedisClusterConfiguration . |
RedisClusterConfiguration(Collection<String> clusterNodes)
Creates
RedisClusterConfiguration for given hostPort combinations. |
RedisClusterConfiguration(PropertySource<?> propertySource)
Creates
RedisClusterConfiguration looking up values in given PropertySource . |
Modifier and Type | Method and Description |
---|---|
void |
addClusterNode(RedisNode node)
Add a cluster node to configuration.
|
RedisClusterConfiguration |
clusterNode(RedisNode node) |
RedisClusterConfiguration |
clusterNode(String host,
Integer port) |
boolean |
equals(Object o) |
Set<RedisNode> |
getClusterNodes()
Returns an
Collections.unmodifiableSet(Set) of cluster nodes. |
Integer |
getMaxRedirects() |
RedisPassword |
getPassword()
Get the RedisPassword to use when connecting.
|
String |
getUsername()
Get the username to use when connecting.
|
int |
hashCode() |
void |
setClusterNodes(Iterable<RedisNode> nodes)
Set cluster nodes to connect to.
|
void |
setMaxRedirects(int maxRedirects) |
void |
setPassword(RedisPassword password)
Create and set a
RedisPassword for given String . |
void |
setUsername(String username)
Create and set a username with the given
String . |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
getDatabaseOrElse, getDatabaseOrElse, getHostOrElse, getPasswordOrElse, getPasswordOrElse, getPortOrElse, getUsernameOrElse, isAuthenticationAware, isClusterConfiguration, isDatabaseIndexAware, isDomainSocketConfiguration, isHostAndPortAware, isSentinelConfiguration, isStaticMasterReplicaConfiguration
setPassword, setPassword
public RedisClusterConfiguration()
RedisClusterConfiguration
.public RedisClusterConfiguration(Collection<String> clusterNodes)
RedisClusterConfiguration
for given hostPort combinations.
clusterHostAndPorts[0] = 127.0.0.1:23679
clusterHostAndPorts[1] = 127.0.0.1:23680 ...
clusterNodes
- must not be null.public RedisClusterConfiguration(PropertySource<?> propertySource)
RedisClusterConfiguration
looking up values in given PropertySource
.
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
propertySource
- must not be null.public void setClusterNodes(Iterable<RedisNode> nodes)
nodes
- must not be null.public Set<RedisNode> getClusterNodes()
RedisConfiguration.ClusterConfiguration
Collections.unmodifiableSet(Set)
of cluster nodes.getClusterNodes
in interface RedisConfiguration.ClusterConfiguration
Set
of nodes. Never null.public void addClusterNode(RedisNode node)
node
- must not be null.public RedisClusterConfiguration clusterNode(RedisNode node)
public Integer getMaxRedirects()
getMaxRedirects
in interface RedisConfiguration.ClusterConfiguration
public void setMaxRedirects(int maxRedirects)
maxRedirects
- the max number of redirects to follow.public RedisClusterConfiguration clusterNode(String host, Integer port)
host
- Redis cluster node host name or ip address.port
- Redis cluster node port.public void setUsername(@Nullable String username)
RedisConfiguration.WithAuthentication
String
. Requires Redis 6 or newer.setUsername
in interface RedisConfiguration.WithAuthentication
username
- the username.@Nullable public String getUsername()
RedisConfiguration.WithAuthentication
getUsername
in interface RedisConfiguration.WithAuthentication
public RedisPassword getPassword()
RedisConfiguration.WithAuthentication
getPassword
in interface RedisConfiguration.WithAuthentication
RedisPassword.none()
if none set.public void setPassword(RedisPassword password)
RedisConfiguration.WithAuthentication
RedisPassword
for given String
.setPassword
in interface RedisConfiguration.WithAuthentication
password
- must not be null use RedisPassword.none()
instead.Copyright © 2011–2023 Pivotal Software, Inc.. All rights reserved.