java.lang.Object
io.lettuce.core.ClientOptions.Builder
io.lettuce.core.cluster.ClusterClientOptions.Builder
- Enclosing class:
- ClusterClientOptions
public static class ClusterClientOptions.Builder extends ClientOptions.Builder
Builder for
ClusterClientOptions.-
Constructor Summary
Constructors Modifier Constructor Description protectedBuilder() -
Method Summary
Modifier and Type Method Description ClusterClientOptions.BuilderautoReconnect(boolean autoReconnect)Enables or disables auto reconnection on connection loss.ClusterClientOptions.BuilderbufferUsageRatio(int bufferUsageRatio)Deprecated.ClusterClientOptionsbuild()Create a new instance ofClusterClientOptionsClusterClientOptions.BuildercancelCommandsOnReconnectFailure(boolean cancelCommandsOnReconnectFailure)Allows cancelling queued commands in case a reconnect fails.Defaults tofalse.ClusterClientOptions.BuilderdecodeBufferPolicy(DecodeBufferPolicy decodeBufferPolicy)Set the policy to discard read bytes from the decoding aggregation buffer to reclaim memory.ClusterClientOptions.BuilderdisconnectedBehavior(ClientOptions.DisconnectedBehavior disconnectedBehavior)Sets the behavior for command invocation when connections are in a disconnected state.ClusterClientOptions.BuildermaxRedirects(int maxRedirects)Number of maximal cluster redirects (-MOVED and -ASK) to follow in case a key was moved from one node to another node.ClusterClientOptions.BuilderpingBeforeActivateConnection(boolean pingBeforeActivateConnection)Sets the PING before activate connection flag.ClusterClientOptions.BuilderprotocolVersion(ProtocolVersion protocolVersion)Sets theProtocolVersionto use.ClusterClientOptions.BuilderpublishOnScheduler(boolean publishOnScheduler)Use a dedicatedSchedulerto emit reactive data signals.ClusterClientOptions.BuilderrequestQueueSize(int requestQueueSize)Set the per-connection request queue size.ClusterClientOptions.BuilderscriptCharset(Charset scriptCharset)ClusterClientOptions.BuildersocketOptions(SocketOptions socketOptions)Sets the low-levelSocketOptionsfor the connections kept to Redis servers.ClusterClientOptions.BuildersslOptions(SslOptions sslOptions)Sets theSslOptionsfor SSL connections kept to Redis servers.ClusterClientOptions.BuildersuspendReconnectOnProtocolFailure(boolean suspendReconnectOnProtocolFailure)Suspends reconnect when reconnects run into protocol failures (SSL verification, PING before connect fails).ClusterClientOptions.BuildertimeoutOptions(TimeoutOptions timeoutOptions)Sets theTimeoutOptionsto expire and cancel commands.ClusterClientOptions.BuildertopologyRefreshOptions(ClusterTopologyRefreshOptions topologyRefreshOptions)Sets theClusterTopologyRefreshOptionsfor detailed control of topology updates.ClusterClientOptions.BuildervalidateClusterNodeMembership(boolean validateClusterNodeMembership)Validate the cluster node membership before allowing connections to a cluster node.
-
Constructor Details
-
Builder
protected Builder()
-
-
Method Details
-
autoReconnect
Description copied from class:ClientOptions.BuilderEnables or disables auto reconnection on connection loss. Defaults totrue. SeeClientOptions.DEFAULT_AUTO_RECONNECT.- Overrides:
autoReconnectin classClientOptions.Builder- Parameters:
autoReconnect- true/false- Returns:
this
-
bufferUsageRatio
Deprecated.since 6.0 in favor ofDecodeBufferPolicy.Description copied from class:ClientOptions.BuilderBuffer usage ratio forCommandHandler. This ratio controls how often bytes are discarded during decoding. In particular, when buffer usage reachesbufferUsageRatio / bufferUsageRatio + 1. E.g. settingbufferUsageRatioto 3, will discard read bytes once the buffer usage reaches 75 percent. SeeClientOptions.DEFAULT_BUFFER_USAGE_RATIO.- Overrides:
bufferUsageRatioin classClientOptions.Builder- Parameters:
bufferUsageRatio- the buffer usage ratio. Must be between0and2^31-1, typically a value between 1 and 10 representing 50% to 90%.- Returns:
this
-
cancelCommandsOnReconnectFailure
public ClusterClientOptions.Builder cancelCommandsOnReconnectFailure(boolean cancelCommandsOnReconnectFailure)Description copied from class:ClientOptions.BuilderAllows cancelling queued commands in case a reconnect fails.Defaults tofalse. SeeClientOptions.DEFAULT_CANCEL_CMD_RECONNECT_FAIL.- Overrides:
cancelCommandsOnReconnectFailurein classClientOptions.Builder- Parameters:
cancelCommandsOnReconnectFailure- true/false- Returns:
this
-
decodeBufferPolicy
Description copied from class:ClientOptions.BuilderSet the policy to discard read bytes from the decoding aggregation buffer to reclaim memory.- Overrides:
decodeBufferPolicyin classClientOptions.Builder- Parameters:
decodeBufferPolicy- the policy to use inCommandHandler- Returns:
this- See Also:
DecodeBufferPolicies
-
disconnectedBehavior
public ClusterClientOptions.Builder disconnectedBehavior(ClientOptions.DisconnectedBehavior disconnectedBehavior)Description copied from class:ClientOptions.BuilderSets the behavior for command invocation when connections are in a disconnected state. Defaults totrue. SeeClientOptions.DEFAULT_DISCONNECTED_BEHAVIOR.- Overrides:
disconnectedBehaviorin classClientOptions.Builder- Parameters:
disconnectedBehavior- must not benull.- Returns:
this
-
maxRedirects
Number of maximal cluster redirects (-MOVED and -ASK) to follow in case a key was moved from one node to another node. Defaults to 5. SeeClusterClientOptions.DEFAULT_MAX_REDIRECTS.- Parameters:
maxRedirects- the limit of maximal cluster redirects- Returns:
this
-
pingBeforeActivateConnection
public ClusterClientOptions.Builder pingBeforeActivateConnection(boolean pingBeforeActivateConnection)Description copied from class:ClientOptions.BuilderSets the PING before activate connection flag. Defaults totrue. SeeClientOptions.DEFAULT_PING_BEFORE_ACTIVATE_CONNECTION. This option has no effect unless forcing to use the RESP 2 protocol version.- Overrides:
pingBeforeActivateConnectionin classClientOptions.Builder- Parameters:
pingBeforeActivateConnection- true/false- Returns:
this
-
protocolVersion
Description copied from class:ClientOptions.BuilderSets theProtocolVersionto use. Defaults to RESP3. SeeClientOptions.DEFAULT_PROTOCOL_VERSION.- Overrides:
protocolVersionin classClientOptions.Builder- Parameters:
protocolVersion- version to use.- Returns:
this- See Also:
ProtocolVersion.newestSupported()
-
suspendReconnectOnProtocolFailure
public ClusterClientOptions.Builder suspendReconnectOnProtocolFailure(boolean suspendReconnectOnProtocolFailure)Description copied from class:ClientOptions.BuilderSuspends reconnect when reconnects run into protocol failures (SSL verification, PING before connect fails). Defaults tofalse. SeeClientOptions.DEFAULT_SUSPEND_RECONNECT_PROTO_FAIL.- Overrides:
suspendReconnectOnProtocolFailurein classClientOptions.Builder- Parameters:
suspendReconnectOnProtocolFailure- true/false- Returns:
this
-
publishOnScheduler
Description copied from class:ClientOptions.BuilderUse a dedicatedSchedulerto emit reactive data signals. Enabling this option can be useful for reactive sequences that require a significant amount of processing with a single/a few Redis connections.A single Redis connection operates on a single thread. Operations that require a significant amount of processing can lead to a single-threaded-like behavior for all consumers of the Redis connection. When enabled, data signals will be emitted using a different thread served by
ClientResources.eventExecutorGroup(). Defaults tofalse, seeClientOptions.DEFAULT_PUBLISH_ON_SCHEDULER.- Overrides:
publishOnSchedulerin classClientOptions.Builder- Parameters:
publishOnScheduler- true/false- Returns:
this- See Also:
Subscriber.onNext(Object),ClientResources.eventExecutorGroup()
-
requestQueueSize
Description copied from class:ClientOptions.BuilderSet the per-connection request queue size. The command invocation will lead to aRedisExceptionif the queue size is exceeded. Setting therequestQueueSizeto a lower value will lead earlier to exceptions during overload or while the connection is in a disconnected state. A higher value means hitting the boundary will take longer to occur, but more requests will potentially be queued up and more heap space is used. Defaults toInteger.MAX_VALUE. SeeClientOptions.DEFAULT_REQUEST_QUEUE_SIZE.- Overrides:
requestQueueSizein classClientOptions.Builder- Parameters:
requestQueueSize- the queue size.- Returns:
this
-
scriptCharset
Description copied from class:ClientOptions.BuilderSets the Lua scriptCharsetto use to encodescriptstobyte[]. Defaults toStandardCharsets.UTF_8. SeeClientOptions.DEFAULT_SCRIPT_CHARSET.- Overrides:
scriptCharsetin classClientOptions.Builder- Parameters:
scriptCharset- must not benull.- Returns:
this
-
socketOptions
Description copied from class:ClientOptions.BuilderSets the low-levelSocketOptionsfor the connections kept to Redis servers. SeeClientOptions.DEFAULT_SOCKET_OPTIONS.- Overrides:
socketOptionsin classClientOptions.Builder- Parameters:
socketOptions- must not benull.- Returns:
this
-
sslOptions
Description copied from class:ClientOptions.BuilderSets theSslOptionsfor SSL connections kept to Redis servers. SeeClientOptions.DEFAULT_SSL_OPTIONS.- Overrides:
sslOptionsin classClientOptions.Builder- Parameters:
sslOptions- must not benull.- Returns:
this
-
timeoutOptions
Description copied from class:ClientOptions.BuilderSets theTimeoutOptionsto expire and cancel commands. SeeClientOptions.DEFAULT_TIMEOUT_OPTIONS.- Overrides:
timeoutOptionsin classClientOptions.Builder- Parameters:
timeoutOptions- must not benull.- Returns:
this
-
topologyRefreshOptions
public ClusterClientOptions.Builder topologyRefreshOptions(ClusterTopologyRefreshOptions topologyRefreshOptions)Sets theClusterTopologyRefreshOptionsfor detailed control of topology updates.- Parameters:
topologyRefreshOptions- theClusterTopologyRefreshOptions- Returns:
this
-
validateClusterNodeMembership
public ClusterClientOptions.Builder validateClusterNodeMembership(boolean validateClusterNodeMembership)Validate the cluster node membership before allowing connections to a cluster node. Defaults totrue. SeeClusterClientOptions.DEFAULT_VALIDATE_CLUSTER_MEMBERSHIP.- Parameters:
validateClusterNodeMembership-trueif validation is enabled.- Returns:
this
-
build
Create a new instance ofClusterClientOptions- Overrides:
buildin classClientOptions.Builder- Returns:
- new instance of
ClusterClientOptions
-
DecodeBufferPolicy.