java.lang.Object
io.lettuce.core.ClientOptions.Builder
- Direct Known Subclasses:
ClusterClientOptions.Builder
- Enclosing class:
- ClientOptions
public static class ClientOptions.Builder extends Object
Builder for
ClientOptions.-
Constructor Summary
Constructors Modifier Constructor Description protectedBuilder() -
Method Summary
Modifier and Type Method Description ClientOptions.BuilderautoReconnect(boolean autoReconnect)Enables or disables auto reconnection on connection loss.ClientOptions.BuilderbufferUsageRatio(int bufferUsageRatio)Deprecated.ClientOptionsbuild()Create a new instance ofClientOptions.ClientOptions.BuildercancelCommandsOnReconnectFailure(boolean cancelCommandsOnReconnectFailure)Allows cancelling queued commands in case a reconnect fails.Defaults tofalse.ClientOptions.BuilderdecodeBufferPolicy(DecodeBufferPolicy policy)Set the policy to discard read bytes from the decoding aggregation buffer to reclaim memory.ClientOptions.BuilderdisconnectedBehavior(ClientOptions.DisconnectedBehavior disconnectedBehavior)Sets the behavior for command invocation when connections are in a disconnected state.ClientOptions.BuilderpingBeforeActivateConnection(boolean pingBeforeActivateConnection)Sets the PING before activate connection flag.ClientOptions.BuilderprotocolVersion(ProtocolVersion protocolVersion)Sets theProtocolVersionto use.ClientOptions.BuilderpublishOnScheduler(boolean publishOnScheduler)Use a dedicatedSchedulerto emit reactive data signals.ClientOptions.BuilderrequestQueueSize(int requestQueueSize)Set the per-connection request queue size.ClientOptions.BuilderscriptCharset(Charset scriptCharset)ClientOptions.BuildersocketOptions(SocketOptions socketOptions)Sets the low-levelSocketOptionsfor the connections kept to Redis servers.ClientOptions.BuildersslOptions(SslOptions sslOptions)Sets theSslOptionsfor SSL connections kept to Redis servers.ClientOptions.BuildersuspendReconnectOnProtocolFailure(boolean suspendReconnectOnProtocolFailure)Suspends reconnect when reconnects run into protocol failures (SSL verification, PING before connect fails).ClientOptions.BuildertimeoutOptions(TimeoutOptions timeoutOptions)Sets theTimeoutOptionsto expire and cancel commands.
-
Constructor Details
-
Builder
protected Builder()
-
-
Method Details
-
autoReconnect
Enables or disables auto reconnection on connection loss. Defaults totrue. SeeClientOptions.DEFAULT_AUTO_RECONNECT.- Parameters:
autoReconnect- true/false- Returns:
this
-
cancelCommandsOnReconnectFailure
public ClientOptions.Builder cancelCommandsOnReconnectFailure(boolean cancelCommandsOnReconnectFailure)Allows cancelling queued commands in case a reconnect fails.Defaults tofalse. SeeClientOptions.DEFAULT_CANCEL_CMD_RECONNECT_FAIL.- Parameters:
cancelCommandsOnReconnectFailure- true/false- Returns:
this
-
bufferUsageRatio
Deprecated.since 6.0 in favor ofDecodeBufferPolicy.Buffer 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.- Parameters:
bufferUsageRatio- the buffer usage ratio. Must be between0and2^31-1, typically a value between 1 and 10 representing 50% to 90%.- Returns:
this- Since:
- 5.2
-
decodeBufferPolicy
Set the policy to discard read bytes from the decoding aggregation buffer to reclaim memory.- Parameters:
policy- the policy to use inCommandHandler- Returns:
this- Since:
- 6.0
- See Also:
DecodeBufferPolicies
-
disconnectedBehavior
public ClientOptions.Builder disconnectedBehavior(ClientOptions.DisconnectedBehavior disconnectedBehavior)Sets the behavior for command invocation when connections are in a disconnected state. Defaults totrue. SeeClientOptions.DEFAULT_DISCONNECTED_BEHAVIOR.- Parameters:
disconnectedBehavior- must not benull.- Returns:
this
-
pingBeforeActivateConnection
Sets 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.- Parameters:
pingBeforeActivateConnection- true/false- Returns:
this
-
protocolVersion
Sets theProtocolVersionto use. Defaults to RESP3. SeeClientOptions.DEFAULT_PROTOCOL_VERSION.- Parameters:
protocolVersion- version to use.- Returns:
this- Since:
- 6.0
- See Also:
ProtocolVersion.newestSupported()
-
publishOnScheduler
Use 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.- Parameters:
publishOnScheduler- true/false- Returns:
this- Since:
- 5.2
- See Also:
Subscriber.onNext(Object),ClientResources.eventExecutorGroup()
-
requestQueueSize
Set 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.- Parameters:
requestQueueSize- the queue size.- Returns:
this
-
scriptCharset
Sets the Lua scriptCharsetto use to encodescriptstobyte[]. Defaults toStandardCharsets.UTF_8. SeeClientOptions.DEFAULT_SCRIPT_CHARSET.- Parameters:
scriptCharset- must not benull.- Returns:
this- Since:
- 6.0
-
socketOptions
Sets the low-levelSocketOptionsfor the connections kept to Redis servers. SeeClientOptions.DEFAULT_SOCKET_OPTIONS.- Parameters:
socketOptions- must not benull.- Returns:
this
-
sslOptions
Sets theSslOptionsfor SSL connections kept to Redis servers. SeeClientOptions.DEFAULT_SSL_OPTIONS.- Parameters:
sslOptions- must not benull.- Returns:
this
-
suspendReconnectOnProtocolFailure
public ClientOptions.Builder suspendReconnectOnProtocolFailure(boolean suspendReconnectOnProtocolFailure)Suspends reconnect when reconnects run into protocol failures (SSL verification, PING before connect fails). Defaults tofalse. SeeClientOptions.DEFAULT_SUSPEND_RECONNECT_PROTO_FAIL.- Parameters:
suspendReconnectOnProtocolFailure- true/false- Returns:
this
-
timeoutOptions
Sets theTimeoutOptionsto expire and cancel commands. SeeClientOptions.DEFAULT_TIMEOUT_OPTIONS.- Parameters:
timeoutOptions- must not benull.- Returns:
this- Since:
- 5.1
-
build
Create a new instance ofClientOptions.- Returns:
- new instance of
ClientOptions
-
DecodeBufferPolicy.