Class RedisStaticMasterReplicaConfiguration
java.lang.Object
org.springframework.data.redis.connection.RedisStaticMasterReplicaConfiguration
- All Implemented Interfaces:
RedisConfiguration
,RedisConfiguration.StaticMasterReplicaConfiguration
,RedisConfiguration.WithAuthentication
,RedisConfiguration.WithDatabaseIndex
,RedisConfiguration.WithPassword
public class RedisStaticMasterReplicaConfiguration
extends Object
implements RedisConfiguration, RedisConfiguration.StaticMasterReplicaConfiguration
Configuration class used for setting up
Please also note that a Master/Replica connection cannot be used for Pub/Sub operations.
RedisConnection
via RedisConnectionFactory
using the provided
Master / Replica configuration to nodes know to not change address. Eg. when connecting to
AWS ElastiCache with Read Replicas. Please also note that a Master/Replica connection cannot be used for Pub/Sub operations.
- Since:
- 2.1
- Author:
- Mark Paluch, Christoph Strobl, Tamer Soliman
-
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
ConstructorDescriptionRedisStaticMasterReplicaConfiguration
(String hostName) Create a newRedisConfiguration.StaticMasterReplicaConfiguration
givenhostName
.RedisStaticMasterReplicaConfiguration
(String hostName, int port) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add anode
to the list of nodes givenhostName
.boolean
int
Get the database index to use.getNodes()
Get the RedisPassword to use when connecting.Get the username to use when connecting.int
hashCode()
Add anode
to the list of nodes givenhostName
.void
setDatabase
(int index) Set the database index to use.void
setPassword
(RedisPassword password) Create and set aRedisPassword
for givenString
.void
setUsername
(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, wait
Methods inherited from interface org.springframework.data.redis.connection.RedisConfiguration
getDatabaseOrElse, getPasswordOrElse
Methods inherited from interface org.springframework.data.redis.connection.RedisConfiguration.WithAuthentication
setPassword, setPassword
-
Constructor Details
-
RedisStaticMasterReplicaConfiguration
Create a newRedisConfiguration.StaticMasterReplicaConfiguration
givenhostName
.- Parameters:
hostName
- must not be null or empty.
-
RedisStaticMasterReplicaConfiguration
- Parameters:
hostName
- must not be null or empty.port
- a valid TCP port (1-65535).
-
-
Method Details
-
addNode
Add anode
to the list of nodes givenhostName
.- Parameters:
hostName
- must not be null or empty.port
- a valid TCP port (1-65535).
-
node
Add anode
to the list of nodes givenhostName
.- Parameters:
hostName
- must not be null or empty.- Returns:
this
RedisConfiguration.StaticMasterReplicaConfiguration
.
-
node
- Parameters:
hostName
- must not be null or empty.port
- a valid TCP port (1-65535).- Returns:
this
RedisConfiguration.StaticMasterReplicaConfiguration
.
-
getDatabase
public int getDatabase()Description copied from interface:RedisConfiguration.WithDatabaseIndex
Get the database index to use.- Specified by:
getDatabase
in interfaceRedisConfiguration.WithDatabaseIndex
- Returns:
zero
by default.
-
setDatabase
public void setDatabase(int index) Description copied from interface:RedisConfiguration.WithDatabaseIndex
Set the database index to use.- Specified by:
setDatabase
in interfaceRedisConfiguration.WithDatabaseIndex
-
setUsername
Description copied from interface:RedisConfiguration.WithAuthentication
Create and set a username with the givenString
. Requires Redis 6 or newer.- Specified by:
setUsername
in interfaceRedisConfiguration.WithAuthentication
- Parameters:
username
- the username.
-
getUsername
Description copied from interface:RedisConfiguration.WithAuthentication
Get the username to use when connecting.- Specified by:
getUsername
in interfaceRedisConfiguration.WithAuthentication
- Returns:
- null if none set.
-
getPassword
Description copied from interface:RedisConfiguration.WithAuthentication
Get the RedisPassword to use when connecting.- Specified by:
getPassword
in interfaceRedisConfiguration.WithAuthentication
- Returns:
RedisPassword.none()
if none set.
-
setPassword
Description copied from interface:RedisConfiguration.WithAuthentication
Create and set aRedisPassword
for givenString
.- Specified by:
setPassword
in interfaceRedisConfiguration.WithAuthentication
- Parameters:
password
- must not be null useRedisPassword.none()
instead.
-
getNodes
- Specified by:
getNodes
in interfaceRedisConfiguration.StaticMasterReplicaConfiguration
- Returns:
- unmodifiable
List
ofnodes
.
-
equals
-
hashCode
public int hashCode()
-