java.lang.Object
io.lettuce.core.ClientOptions
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ClusterClientOptions
public class ClientOptions extends Object implements Serializable
Client Options to control the behavior of
RedisClient.- Author:
- Mark Paluch, Gavin Cook
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classClientOptions.BuilderBuilder forClientOptions.static classClientOptions.DisconnectedBehaviorBehavior of connections in disconnected state. -
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_AUTO_RECONNECTstatic intDEFAULT_BUFFER_USAGE_RATIOstatic booleanDEFAULT_CANCEL_CMD_RECONNECT_FAILstatic ClientOptions.DisconnectedBehaviorDEFAULT_DISCONNECTED_BEHAVIORstatic booleanDEFAULT_PING_BEFORE_ACTIVATE_CONNECTIONstatic ProtocolVersionDEFAULT_PROTOCOL_VERSIONstatic booleanDEFAULT_PUBLISH_ON_SCHEDULERstatic intDEFAULT_REQUEST_QUEUE_SIZEstatic CharsetDEFAULT_SCRIPT_CHARSETstatic SocketOptionsDEFAULT_SOCKET_OPTIONSstatic SslOptionsDEFAULT_SSL_OPTIONSstatic booleanDEFAULT_SUSPEND_RECONNECT_PROTO_FAILstatic TimeoutOptionsDEFAULT_TIMEOUT_OPTIONS -
Constructor Summary
Constructors Modifier Constructor Description protectedClientOptions(ClientOptions original)protectedClientOptions(ClientOptions.Builder builder) -
Method Summary
Modifier and Type Method Description static ClientOptions.Builderbuilder()Returns a newClientOptions.Builderto constructClientOptions.static ClientOptionscopyOf(ClientOptions options)Create a copy of optionsstatic ClientOptionscreate()Create a new instance ofClientOptionswith default settings.intgetBufferUsageRatio()Deprecated.ProtocolVersiongetConfiguredProtocolVersion()Returns the configuredProtocolVersion.DecodeBufferPolicygetDecodeBufferPolicy()Returns theDecodeBufferPolicyused to reclaim memory.ClientOptions.DisconnectedBehaviorgetDisconnectedBehavior()Behavior for command invocation when connections are in a disconnected state.ProtocolVersiongetProtocolVersion()Returns theProtocolVersionto use.intgetRequestQueueSize()Request queue size for a connection.CharsetgetScriptCharset()Returns the Lua scriptCharset.SocketOptionsgetSocketOptions()Returns theSocketOptions.SslOptionsgetSslOptions()Returns theSslOptions.TimeoutOptionsgetTimeoutOptions()Returns theTimeoutOptions.booleanisAutoReconnect()Controls auto-reconnect behavior on connections.booleanisCancelCommandsOnReconnectFailure()If this flag istrueany queued commands will be canceled when a reconnect fails within the activation sequence.booleanisPingBeforeActivateConnection()Enables initial PING barrier before any connection is usable.booleanisPublishOnScheduler()Use a dedicatedSchedulerto emit reactive data signals.booleanisSuspendReconnectOnProtocolFailure()If this flag istruethe reconnect will be suspended on protocol errors.ClientOptions.Buildermutate()Returns a builder to create newClientOptionswhose settings are replicated from the currentClientOptions.
-
Field Details
-
DEFAULT_AUTO_RECONNECT
public static final boolean DEFAULT_AUTO_RECONNECT- See Also:
- Constant Field Values
-
DEFAULT_BUFFER_USAGE_RATIO
public static final int DEFAULT_BUFFER_USAGE_RATIO- See Also:
- Constant Field Values
-
DEFAULT_CANCEL_CMD_RECONNECT_FAIL
public static final boolean DEFAULT_CANCEL_CMD_RECONNECT_FAIL- See Also:
- Constant Field Values
-
DEFAULT_DISCONNECTED_BEHAVIOR
-
DEFAULT_PUBLISH_ON_SCHEDULER
public static final boolean DEFAULT_PUBLISH_ON_SCHEDULER- See Also:
- Constant Field Values
-
DEFAULT_PING_BEFORE_ACTIVATE_CONNECTION
public static final boolean DEFAULT_PING_BEFORE_ACTIVATE_CONNECTION- See Also:
- Constant Field Values
-
DEFAULT_PROTOCOL_VERSION
-
DEFAULT_REQUEST_QUEUE_SIZE
public static final int DEFAULT_REQUEST_QUEUE_SIZE- See Also:
- Constant Field Values
-
DEFAULT_SCRIPT_CHARSET
-
DEFAULT_SOCKET_OPTIONS
-
DEFAULT_SSL_OPTIONS
-
DEFAULT_SUSPEND_RECONNECT_PROTO_FAIL
public static final boolean DEFAULT_SUSPEND_RECONNECT_PROTO_FAIL- See Also:
- Constant Field Values
-
DEFAULT_TIMEOUT_OPTIONS
-
-
Constructor Details
-
ClientOptions
-
ClientOptions
-
-
Method Details
-
copyOf
Create a copy of options- Parameters:
options- the original- Returns:
- A new instance of
ClientOptionscontaining the values of options
-
builder
Returns a newClientOptions.Builderto constructClientOptions.- Returns:
- a new
ClientOptions.Builderto constructClientOptions.
-
create
Create a new instance ofClientOptionswith default settings.- Returns:
- a new instance of
ClientOptionswith default settings
-
mutate
Returns a builder to create newClientOptionswhose settings are replicated from the currentClientOptions.- Returns:
- a
ClientOptions.Builderto create newClientOptionswhose settings are replicated from the currentClientOptions. - Since:
- 5.1
-
isAutoReconnect
public boolean isAutoReconnect()Controls auto-reconnect behavior on connections. If auto-reconnect istrue(default), it is enabled. As soon as a connection gets closed/reset without the intention to close it, the client will try to reconnect and re-issue any queued commands. This flag has also the effect that disconnected connections will refuse commands and cancel these with an exception.- Returns:
trueif auto-reconnect is enabled.
-
isCancelCommandsOnReconnectFailure
public boolean isCancelCommandsOnReconnectFailure()If this flag istrueany queued commands will be canceled when a reconnect fails within the activation sequence. Default isfalse.- Returns:
trueif commands should be cancelled on reconnect failures.
-
getDecodeBufferPolicy
Returns theDecodeBufferPolicyused to reclaim memory.- Returns:
- the
DecodeBufferPolicy. - Since:
- 6.0
-
getBufferUsageRatio
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.- Returns:
- zero.
- Since:
- 5.2
-
getDisconnectedBehavior
Behavior for command invocation when connections are in a disconnected state. Defaults totrue. SeeDEFAULT_DISCONNECTED_BEHAVIOR.- Returns:
- the behavior for command invocation when connections are in a disconnected state
-
getRequestQueueSize
public int getRequestQueueSize()Request queue size for a connection. This value applies per connection. The command invocation will throw aRedisExceptionif the queue size is exceeded and a new command is requested. Defaults toInteger.MAX_VALUE.- Returns:
- the request queue size.
-
isPingBeforeActivateConnection
public boolean isPingBeforeActivateConnection()Enables initial PING barrier before any connection is usable. Iftrue(default istrue), every connection and reconnect will issue a PING command and awaits its response before the connection is activated and enabled for use. If the check fails, the connect/reconnect is treated as failure. This option has no effect unless forcing to use the RESP 2 protocol version.- Returns:
trueif PING barrier is enabled.
-
getProtocolVersion
Returns theProtocolVersionto use.- Returns:
- the
ProtocolVersionto use.
-
getConfiguredProtocolVersion
Returns the configuredProtocolVersion. May returnnullif unconfigured.- Returns:
- the
ProtocolVersionto use. May benull. - Since:
- 6.0
-
isPublishOnScheduler
public boolean isPublishOnScheduler()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, seeDEFAULT_PUBLISH_ON_SCHEDULER.- Returns:
trueto use a dedicatedScheduler- Since:
- 5.2
-
isSuspendReconnectOnProtocolFailure
public boolean isSuspendReconnectOnProtocolFailure()If this flag istruethe reconnect will be suspended on protocol errors. Protocol errors are errors while SSL negotiation or when PING before connect fails.- Returns:
trueif reconnect will be suspended on protocol errors.
-
getScriptCharset
Returns the Lua scriptCharset.- Returns:
- the script
Charset. - Since:
- 6.0
-
getSocketOptions
Returns theSocketOptions.- Returns:
- the
SocketOptions.
-
getSslOptions
Returns theSslOptions.- Returns:
- the
SslOptions.
-
getTimeoutOptions
Returns theTimeoutOptions.- Returns:
- the
TimeoutOptions. - Since:
- 5.1
-
DecodeBufferPolicy.