public class RedisSentinelConnectOptions extends RedisConnectOptions
| Constructor and Description |
|---|
RedisSentinelConnectOptions() |
RedisSentinelConnectOptions(JsonObject json) |
RedisSentinelConnectOptions(RedisOptions options) |
RedisSentinelConnectOptions(RedisSentinelConnectOptions other) |
| Modifier and Type | Method and Description |
|---|---|
RedisSentinelConnectOptions |
addConnectionString(String connectionString)
Adds a connection string (endpoint) to use while connecting to the redis server.
|
String |
getMasterName()
Get the name of the master set.
|
RedisRole |
getRole()
Get the client role; that is, to which kind of node should the connection be established.
|
long |
getTopologyCacheTTL()
Returns the TTL of the topology cache.
|
boolean |
isAutoFailover()
Returns whether automatic failover is enabled.
|
RedisSentinelConnectOptions |
setAutoFailover(boolean autoFailover)
Sets whether automatic failover is enabled.
|
RedisSentinelConnectOptions |
setConnectionString(String connectionString)
Sets a single connection string (endpoint) to use while connecting to the redis server.
|
RedisSentinelConnectOptions |
setEndpoints(List<String> endpoints)
Set the endpoints to use while connecting to the redis server.
|
RedisSentinelConnectOptions |
setMasterName(String masterName)
Set the name of the master set.
|
RedisSentinelConnectOptions |
setMaxNestedArrays(int maxNestedArrays)
Tune how much nested arrays are allowed on a redis response.
|
RedisSentinelConnectOptions |
setMaxWaitingHandlers(int maxWaitingHandlers)
The client will always work on pipeline mode, this means that messages can start queueing.
|
RedisSentinelConnectOptions |
setPassword(String password)
Set the default password for cluster/sentinel connections.
|
RedisSentinelConnectOptions |
setPreferredProtocolVersion(ProtocolVersion preferredProtocolVersion)
Sets the preferred protocol version to be used during protocol negotiation.
|
RedisSentinelConnectOptions |
setProtocolNegotiation(boolean protocolNegotiation)
Should the client perform
REST protocol negotiation during the connection acquire. |
RedisSentinelConnectOptions |
setRole(RedisRole role)
Set the client role; that is, to which kind of node should the connection be established.
|
RedisSentinelConnectOptions |
setTopologyCacheTTL(long topologyCacheTTL)
Sets the TTL of the topology cache.
|
JsonObject |
toJson()
Converts this object to JSON notation.
|
getEndpoint, getEndpoints, getMaxNestedArrays, getMaxWaitingHandlers, getPassword, getPreferredProtocolVersion, isProtocolNegotiationpublic RedisSentinelConnectOptions()
public RedisSentinelConnectOptions(RedisOptions options)
public RedisSentinelConnectOptions(RedisSentinelConnectOptions other)
public RedisSentinelConnectOptions(JsonObject json)
public RedisRole getRole()
public RedisSentinelConnectOptions setRole(RedisRole role)
role - the rolepublic String getMasterName()
public RedisSentinelConnectOptions setMasterName(String masterName)
masterName - the master set namepublic boolean isAutoFailover()
RedisRole.MASTER and is ignored otherwise.
If enabled, the sentinel client will additionally create a connection to one sentinel node
and watch for failover events. When new master is elected, all connections to the old master
are automatically closed and new connections to the new master are created. Note that
these new connections will not have the same event handlers
(handler(),
exceptionHandler() and
endHandler()), will not be
in the same streaming mode (pause(),
resume() and fetch()),
and will not watch the same subscriptions (SUBSCRIBE, PSUBSCRIBE, etc.)
as the old ones. In other words, automatic failover makes sense for connections executing
regular commands, but not for connections used to subscribe to Redis pub/sub channels.
Note that there is a brief period of time between the old master failing and the new master being elected when the existing connections will temporarily fail all operations. After the new master is elected, the connections will automatically fail over and start working again.
public RedisSentinelConnectOptions setAutoFailover(boolean autoFailover)
RedisRole.MASTER and is ignored otherwise.
If enabled, the sentinel client will additionally create a connection to one sentinel node
and watch for failover events. When new master is elected, all connections to the old master
are automatically closed and new connections to the new master are created. Note that
these new connections will not have the same event handlers
(handler(),
exceptionHandler() and
endHandler()), will not be
in the same streaming mode (pause(),
resume() and fetch()),
and will not watch the same subscriptions (SUBSCRIBE, PSUBSCRIBE, etc.)
as the old ones. In other words, automatic failover makes sense for connections executing
regular commands, but not for connections used to subscribe to Redis pub/sub channels.
Note that there is a brief period of time between the old master failing and the new master being elected when the existing connections will temporarily fail all operations. After the new master is elected, the connections will automatically fail over and start working again.
autoFailover - whether automatic failover should be enabledpublic long getTopologyCacheTTL()
public RedisSentinelConnectOptions setTopologyCacheTTL(long topologyCacheTTL)
topologyCacheTTL - the TTL of the hash topology cache, in millispublic RedisSentinelConnectOptions setMaxNestedArrays(int maxNestedArrays)
RedisConnectOptionssetMaxNestedArrays in class RedisConnectOptionsmaxNestedArrays - the configured max nested arrays allowance.public RedisSentinelConnectOptions setProtocolNegotiation(boolean protocolNegotiation)
RedisConnectOptionsREST protocol negotiation during the connection acquire.
By default this is true, but there are situations when using broken servers it may
be useful to skip this and always fallback to RESP2 without using the HELLO
command.setProtocolNegotiation in class RedisConnectOptionsprotocolNegotiation - false to disable HELLO (not recommended) unless reasons...public RedisSentinelConnectOptions setPreferredProtocolVersion(ProtocolVersion preferredProtocolVersion)
RedisConnectOptionssetPreferredProtocolVersion in class RedisConnectOptionspreferredProtocolVersion - preferred protocol versionpublic RedisSentinelConnectOptions setPassword(String password)
RedisConnectOptionssetPassword in class RedisConnectOptionspassword - the default passwordpublic RedisSentinelConnectOptions setEndpoints(List<String> endpoints)
RedisConnectOptionssetEndpoints in class RedisConnectOptionsendpoints - list of socket addresses.public RedisSentinelConnectOptions addConnectionString(String connectionString)
RedisConnectOptionsaddConnectionString in class RedisConnectOptionsconnectionString - a string URI following the scheme: redis://[username:password@][host][:port][/database]public RedisSentinelConnectOptions setConnectionString(String connectionString)
RedisConnectOptionssetConnectionString in class RedisConnectOptionsconnectionString - a string following the scheme: redis://[username:password@][host][:port][/[database].public RedisSentinelConnectOptions setMaxWaitingHandlers(int maxWaitingHandlers)
RedisConnectOptionssetMaxWaitingHandlers in class RedisConnectOptionsmaxWaitingHandlers - max allowed queued waiting handlers.public JsonObject toJson()
toJson in class RedisConnectOptionsCopyright © 2025 Eclipse. All rights reserved.