public static class ClientOptions.Builder extends Object
ClientOptions
.Modifier | Constructor and Description |
---|---|
protected |
Builder() |
Modifier and Type | Method and Description |
---|---|
ClientOptions.Builder |
autoReconnect(boolean autoReconnect)
Enables or disables auto reconnection on connection loss.
|
ClientOptions.Builder |
bufferUsageRatio(int bufferUsageRatio)
Deprecated.
since 6.0 in favor of
DecodeBufferPolicy . |
ClientOptions |
build()
Create a new instance of
ClientOptions . |
ClientOptions.Builder |
cancelCommandsOnReconnectFailure(boolean cancelCommandsOnReconnectFailure)
Deprecated.
since 6.2, to be removed with 7.0. This feature is unsafe and may cause protocol offsets if true (i.e.
Redis commands are completed with previous command values).
|
ClientOptions.Builder |
decodeBufferPolicy(DecodeBufferPolicy policy)
Set the policy to discard read bytes from the decoding aggregation buffer to reclaim memory.
|
ClientOptions.Builder |
disconnectedBehavior(ClientOptions.DisconnectedBehavior disconnectedBehavior)
Sets the behavior for command invocation when connections are in a disconnected state.
|
ClientOptions.Builder |
pingBeforeActivateConnection(boolean pingBeforeActivateConnection)
Perform a lightweight PING connection handshake when establishing a Redis connection.
|
ClientOptions.Builder |
protocolVersion(ProtocolVersion protocolVersion)
Sets the
ProtocolVersion to use. |
ClientOptions.Builder |
publishOnScheduler(boolean publishOnScheduler)
Use a dedicated
Scheduler to emit reactive data signals. |
ClientOptions.Builder |
requestQueueSize(int requestQueueSize)
Set the per-connection request queue size.
|
ClientOptions.Builder |
scriptCharset(Charset scriptCharset)
|
ClientOptions.Builder |
socketOptions(SocketOptions socketOptions)
Sets the low-level
SocketOptions for the connections kept to Redis servers. |
ClientOptions.Builder |
sslOptions(SslOptions sslOptions)
Sets the
SslOptions for SSL connections kept to Redis servers. |
ClientOptions.Builder |
suspendReconnectOnProtocolFailure(boolean suspendReconnectOnProtocolFailure)
Suspends reconnect when reconnects run into protocol failures (SSL verification, PING before connect fails).
|
ClientOptions.Builder |
timeoutOptions(TimeoutOptions timeoutOptions)
Sets the
TimeoutOptions to expire and cancel commands. |
public ClientOptions.Builder autoReconnect(boolean autoReconnect)
true
. See
ClientOptions.DEFAULT_AUTO_RECONNECT
.autoReconnect
- true/falsethis
@Deprecated public ClientOptions.Builder cancelCommandsOnReconnectFailure(boolean cancelCommandsOnReconnectFailure)
false
. See
ClientOptions.DEFAULT_CANCEL_CMD_RECONNECT_FAIL
. This flag is deprecated and should not be used as it can lead to race
conditions and protocol offsets. The reason is that it internally calls reset() which causes a protocol offset.
See StatefulConnection.reset()
cancelCommandsOnReconnectFailure
- true/falsethis
@Deprecated public ClientOptions.Builder bufferUsageRatio(int bufferUsageRatio)
DecodeBufferPolicy
.CommandHandler
. This ratio controls how often bytes are
discarded during decoding. In particular, when buffer usage reaches bufferUsageRatio / bufferUsageRatio + 1
.
E.g. setting bufferUsageRatio
to 3, will discard read bytes once the buffer usage reaches 75
percent. See ClientOptions.DEFAULT_BUFFER_USAGE_RATIO
.bufferUsageRatio
- the buffer usage ratio. Must be between 0
and 2^31-1
, typically a value
between 1 and 10 representing 50% to 90%.this
public ClientOptions.Builder decodeBufferPolicy(DecodeBufferPolicy policy)
policy
- the policy to use in CommandHandler
this
DecodeBufferPolicies
public ClientOptions.Builder disconnectedBehavior(ClientOptions.DisconnectedBehavior disconnectedBehavior)
true
. See
ClientOptions.DEFAULT_DISCONNECTED_BEHAVIOR
.disconnectedBehavior
- must not be null
.this
public ClientOptions.Builder pingBeforeActivateConnection(boolean pingBeforeActivateConnection)
true
(default is true
, ClientOptions.DEFAULT_PING_BEFORE_ACTIVATE_CONNECTION
), every connection and reconnect will
issue a PING command and await its response before the connection is activated and enabled for use. If the
check fails, the connect/reconnect is treated as a failure. This option has no effect unless forced to use the RESP 2
protocol version. RESP 3/protocol discovery performs a HELLO
handshake.
The PING handshake validates whether the other end of the connected socket is a service that behaves like a Redis server.
pingBeforeActivateConnection
- true/falsethis
public ClientOptions.Builder protocolVersion(ProtocolVersion protocolVersion)
ProtocolVersion
to use. Defaults to RESP3. See ClientOptions.DEFAULT_PROTOCOL_VERSION
.protocolVersion
- version to use.this
ProtocolVersion.newestSupported()
public ClientOptions.Builder publishOnScheduler(boolean publishOnScheduler)
Scheduler
to 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 to false
,
see ClientOptions.DEFAULT_PUBLISH_ON_SCHEDULER
.
publishOnScheduler
- true/falsethis
Subscriber.onNext(Object)
,
ClientResources.eventExecutorGroup()
public ClientOptions.Builder requestQueueSize(int requestQueueSize)
RedisException
if the queue
size is exceeded. Setting the requestQueueSize
to 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 to
Integer.MAX_VALUE
. See ClientOptions.DEFAULT_REQUEST_QUEUE_SIZE
.requestQueueSize
- the queue size.this
public ClientOptions.Builder scriptCharset(Charset scriptCharset)
Charset
to use to encode scripts
to byte[]
. Defaults to
StandardCharsets.UTF_8
. See ClientOptions.DEFAULT_SCRIPT_CHARSET
.scriptCharset
- must not be null
.this
public ClientOptions.Builder socketOptions(SocketOptions socketOptions)
SocketOptions
for the connections kept to Redis servers. See
ClientOptions.DEFAULT_SOCKET_OPTIONS
.socketOptions
- must not be null
.this
public ClientOptions.Builder sslOptions(SslOptions sslOptions)
SslOptions
for SSL connections kept to Redis servers. See ClientOptions.DEFAULT_SSL_OPTIONS
.sslOptions
- must not be null
.this
public ClientOptions.Builder suspendReconnectOnProtocolFailure(boolean suspendReconnectOnProtocolFailure)
false
. See ClientOptions.DEFAULT_SUSPEND_RECONNECT_PROTO_FAIL
.suspendReconnectOnProtocolFailure
- true/falsethis
public ClientOptions.Builder timeoutOptions(TimeoutOptions timeoutOptions)
TimeoutOptions
to expire and cancel commands. See ClientOptions.DEFAULT_TIMEOUT_OPTIONS
.timeoutOptions
- must not be null
.this
public ClientOptions build()
ClientOptions
.ClientOptions
Copyright © 2023 lettuce.io. All rights reserved.