public class ClientOptions extends Object implements Serializable
RedisClient.| Modifier and Type | Class and Description |
|---|---|
static class |
ClientOptions.Builder
Builder for
ClientOptions. |
static class |
ClientOptions.DisconnectedBehavior
Behavior of connections in disconnected state.
|
static class |
ClientOptions.ReauthenticateBehavior
Defines the re-authentication behavior of the Redis client.
|
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEFAULT_AUTO_RECONNECT |
static int |
DEFAULT_BUFFER_USAGE_RATIO |
static boolean |
DEFAULT_CANCEL_CMD_RECONNECT_FAIL |
static ClientOptions.DisconnectedBehavior |
DEFAULT_DISCONNECTED_BEHAVIOR |
static Supplier<JsonParser> |
DEFAULT_JSON_PARSER |
static boolean |
DEFAULT_PING_BEFORE_ACTIVATE_CONNECTION |
static ProtocolVersion |
DEFAULT_PROTOCOL_VERSION |
static boolean |
DEFAULT_PUBLISH_ON_SCHEDULER |
static ReadOnlyCommands.ReadOnlyPredicate |
DEFAULT_READ_ONLY_COMMANDS |
static ClientOptions.ReauthenticateBehavior |
DEFAULT_REAUTHENTICATE_BEHAVIOUR |
static Predicate<RedisCommand<?,?,?>> |
DEFAULT_REPLAY_FILTER |
static int |
DEFAULT_REQUEST_QUEUE_SIZE |
static Charset |
DEFAULT_SCRIPT_CHARSET |
static SocketOptions |
DEFAULT_SOCKET_OPTIONS |
static SslOptions |
DEFAULT_SSL_OPTIONS |
static boolean |
DEFAULT_SUSPEND_RECONNECT_PROTO_FAIL |
static TimeoutOptions |
DEFAULT_TIMEOUT_OPTIONS |
static boolean |
DEFAULT_USE_HASH_INDEX_QUEUE |
| Modifier | Constructor and Description |
|---|---|
protected |
ClientOptions(ClientOptions.Builder builder) |
protected |
ClientOptions(ClientOptions original) |
| Modifier and Type | Method and Description |
|---|---|
static ClientOptions.Builder |
builder()
Returns a new
ClientOptions.Builder to construct ClientOptions. |
static ClientOptions |
copyOf(ClientOptions options)
Create a copy of options
|
static ClientOptions |
create()
Create a new instance of
ClientOptions with default settings. |
int |
getBufferUsageRatio()
Deprecated.
since 6.0 in favor of
DecodeBufferPolicy. |
ProtocolVersion |
getConfiguredProtocolVersion()
Returns the configured
ProtocolVersion. |
DecodeBufferPolicy |
getDecodeBufferPolicy()
Returns the
DecodeBufferPolicy used to reclaim memory. |
ClientOptions.DisconnectedBehavior |
getDisconnectedBehavior()
Behavior for command invocation when connections are in a disconnected state.
|
Supplier<JsonParser> |
getJsonParser()
Returns the currently set up
JsonParser. |
ProtocolVersion |
getProtocolVersion()
Returns the
ProtocolVersion to use. |
ReadOnlyCommands.ReadOnlyPredicate |
getReadOnlyCommands()
Predicate to identify commands as read-only.
|
ClientOptions.ReauthenticateBehavior |
getReauthenticateBehaviour()
Behavior for re-authentication when the
RedisCredentialsProvider emits new credentials. |
Predicate<RedisCommand<?,?,?>> |
getReplayFilter()
Controls which
RedisCommand will be replayed after a re-connect. |
int |
getRequestQueueSize()
Request queue size for a connection.
|
Charset |
getScriptCharset()
Returns the Lua script
Charset. |
SocketOptions |
getSocketOptions()
Returns the
SocketOptions. |
SslOptions |
getSslOptions()
Returns the
SslOptions. |
TimeoutOptions |
getTimeoutOptions()
Returns the
TimeoutOptions. |
boolean |
isAutoReconnect()
Controls auto-reconnect behavior on connections.
|
boolean |
isCancelCommandsOnReconnectFailure()
Deprecated.
since 6.2, to be removed with 7.0. See
ClientOptions.Builder.cancelCommandsOnReconnectFailure(boolean). |
boolean |
isPingBeforeActivateConnection()
Perform a lightweight PING connection handshake when establishing a Redis connection.
|
boolean |
isPublishOnScheduler()
Use a dedicated
Scheduler to emit reactive data signals. |
boolean |
isSuspendReconnectOnProtocolFailure()
If this flag is
true, the reconnect will be suspended on protocol errors. |
boolean |
isUseHashIndexedQueue()
Whether we should use hash indexed queue, which provides O(1) remove(Object)
|
ClientOptions.Builder |
mutate()
Returns a builder to create new
ClientOptions whose settings are replicated from the current
ClientOptions. |
public static final boolean DEFAULT_AUTO_RECONNECT
public static final Predicate<RedisCommand<?,?,?>> DEFAULT_REPLAY_FILTER
public static final int DEFAULT_BUFFER_USAGE_RATIO
public static final boolean DEFAULT_CANCEL_CMD_RECONNECT_FAIL
public static final ClientOptions.DisconnectedBehavior DEFAULT_DISCONNECTED_BEHAVIOR
public static final ClientOptions.ReauthenticateBehavior DEFAULT_REAUTHENTICATE_BEHAVIOUR
public static final boolean DEFAULT_PUBLISH_ON_SCHEDULER
public static final boolean DEFAULT_PING_BEFORE_ACTIVATE_CONNECTION
public static final ProtocolVersion DEFAULT_PROTOCOL_VERSION
public static final ReadOnlyCommands.ReadOnlyPredicate DEFAULT_READ_ONLY_COMMANDS
public static final int DEFAULT_REQUEST_QUEUE_SIZE
public static final Charset DEFAULT_SCRIPT_CHARSET
public static final SocketOptions DEFAULT_SOCKET_OPTIONS
public static final Supplier<JsonParser> DEFAULT_JSON_PARSER
public static final SslOptions DEFAULT_SSL_OPTIONS
public static final boolean DEFAULT_SUSPEND_RECONNECT_PROTO_FAIL
public static final TimeoutOptions DEFAULT_TIMEOUT_OPTIONS
public static final boolean DEFAULT_USE_HASH_INDEX_QUEUE
protected ClientOptions(ClientOptions.Builder builder)
protected ClientOptions(ClientOptions original)
public static ClientOptions copyOf(ClientOptions options)
options - the originalClientOptions containing the values of optionspublic static ClientOptions.Builder builder()
ClientOptions.Builder to construct ClientOptions.ClientOptions.Builder to construct ClientOptions.public static ClientOptions create()
ClientOptions with default settings.ClientOptions with default settingspublic ClientOptions.Builder mutate()
ClientOptions whose settings are replicated from the current
ClientOptions.ClientOptions.Builder to create new ClientOptions whose settings are replicated from the
current ClientOptions.public boolean isAutoReconnect()
true (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.true if auto-reconnect is enabled.public Predicate<RedisCommand<?,?,?>> getReplayFilter()
RedisCommand will be replayed after a re-connect. The Predicate returns true
if command should be filtered out and not replayed. Defaults to DEFAULT_REPLAY_FILTER.Predicate used to filter out commands to replay@Deprecated public boolean isCancelCommandsOnReconnectFailure()
ClientOptions.Builder.cancelCommandsOnReconnectFailure(boolean).true any queued commands will be canceled when a reconnect fails within the activation sequence.
Default is false.true if commands should be cancelled on reconnect failures.public DecodeBufferPolicy getDecodeBufferPolicy()
DecodeBufferPolicy used to reclaim memory.DecodeBufferPolicy.@Deprecated public int getBufferUsageRatio()
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.public ClientOptions.DisconnectedBehavior getDisconnectedBehavior()
true. See DEFAULT_DISCONNECTED_BEHAVIOR.public ClientOptions.ReauthenticateBehavior getReauthenticateBehaviour()
RedisCredentialsProvider emits new credentials. Defaults to
ClientOptions.ReauthenticateBehavior.DEFAULT.ClientOptions.ReauthenticateBehavior.public ReadOnlyCommands.ReadOnlyPredicate getReadOnlyCommands()
DEFAULT_READ_ONLY_COMMANDS.public int getRequestQueueSize()
RedisException if the queue size is exceeded and a new command is requested. Defaults to
Integer.MAX_VALUE.public boolean isPingBeforeActivateConnection()
true (default
is true), 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.
true if PING handshake is enabled.public ProtocolVersion getProtocolVersion()
ProtocolVersion to use.ProtocolVersion to use.public ProtocolVersion getConfiguredProtocolVersion()
ProtocolVersion. May return null if unconfigured.ProtocolVersion to use. May be null.public boolean isPublishOnScheduler()
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
DEFAULT_PUBLISH_ON_SCHEDULER.
true to use a dedicated Schedulerpublic boolean isSuspendReconnectOnProtocolFailure()
true, the reconnect will be suspended on protocol errors. Protocol errors are errors while SSL
negotiation or when PING before connect fails.true if reconnect will be suspended on protocol errors.public Charset getScriptCharset()
Charset.Charset.public Supplier<JsonParser> getJsonParser()
JsonParser.JsonParser to use.public SocketOptions getSocketOptions()
SocketOptions.SocketOptions.public SslOptions getSslOptions()
SslOptions.SslOptions.public TimeoutOptions getTimeoutOptions()
TimeoutOptions.TimeoutOptions.public boolean isUseHashIndexedQueue()
Copyright © 2025 lettuce.io. All rights reserved.