Module lettuce.core

Class ClientOptions

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
  • 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

      public static final ClientOptions.DisconnectedBehavior 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

      public static final ProtocolVersion DEFAULT_PROTOCOL_VERSION
    • DEFAULT_REQUEST_QUEUE_SIZE

      public static final int DEFAULT_REQUEST_QUEUE_SIZE
      See Also:
      Constant Field Values
    • DEFAULT_SCRIPT_CHARSET

      public static final Charset DEFAULT_SCRIPT_CHARSET
    • DEFAULT_SOCKET_OPTIONS

      public static final SocketOptions DEFAULT_SOCKET_OPTIONS
    • DEFAULT_SSL_OPTIONS

      public static final SslOptions 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

      public static final TimeoutOptions DEFAULT_TIMEOUT_OPTIONS
  • Constructor Details

  • Method Details

    • copyOf

      public static ClientOptions copyOf​(ClientOptions options)
      Create a copy of options
      Parameters:
      options - the original
      Returns:
      A new instance of ClientOptions containing the values of options
    • builder

      public static ClientOptions.Builder builder()
      Returns a new ClientOptions.Builder to construct ClientOptions.
      Returns:
      a new ClientOptions.Builder to construct ClientOptions.
    • create

      public static ClientOptions create()
      Create a new instance of ClientOptions with default settings.
      Returns:
      a new instance of ClientOptions with default settings
    • mutate

      public ClientOptions.Builder mutate()
      Returns a builder to create new ClientOptions whose settings are replicated from the current ClientOptions.
      Returns:
      a ClientOptions.Builder to create new ClientOptions whose settings are replicated from the current ClientOptions.
      Since:
      5.1
    • isAutoReconnect

      public boolean isAutoReconnect()
      Controls auto-reconnect behavior on connections. If auto-reconnect is 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.
      Returns:
      true if auto-reconnect is enabled.
    • isCancelCommandsOnReconnectFailure

      public boolean isCancelCommandsOnReconnectFailure()
      If this flag is true any queued commands will be canceled when a reconnect fails within the activation sequence. Default is false.
      Returns:
      true if commands should be cancelled on reconnect failures.
    • getDecodeBufferPolicy

      public DecodeBufferPolicy getDecodeBufferPolicy()
      Returns the DecodeBufferPolicy used to reclaim memory.
      Returns:
      the DecodeBufferPolicy.
      Since:
      6.0
    • getBufferUsageRatio

      @Deprecated public int getBufferUsageRatio()
      Deprecated.
      since 6.0 in favor of DecodeBufferPolicy.
      Buffer usage ratio for 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.
      Returns:
      zero.
      Since:
      5.2
    • getDisconnectedBehavior

      public ClientOptions.DisconnectedBehavior getDisconnectedBehavior()
      Behavior for command invocation when connections are in a disconnected state. Defaults to true. See DEFAULT_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 a RedisException if the queue size is exceeded and a new command is requested. Defaults to Integer.MAX_VALUE.
      Returns:
      the request queue size.
    • isPingBeforeActivateConnection

      public boolean isPingBeforeActivateConnection()
      Enables initial PING barrier before any connection is usable. If true (default is true ), 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:
      true if PING barrier is enabled.
    • getProtocolVersion

      public ProtocolVersion getProtocolVersion()
      Returns the ProtocolVersion to use.
      Returns:
      the ProtocolVersion to use.
    • getConfiguredProtocolVersion

      public ProtocolVersion getConfiguredProtocolVersion()
      Returns the configured ProtocolVersion. May return null if unconfigured.
      Returns:
      the ProtocolVersion to use. May be null.
      Since:
      6.0
    • isPublishOnScheduler

      public boolean isPublishOnScheduler()
      Use a dedicated 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.

      Returns:
      true to use a dedicated Scheduler
      Since:
      5.2
    • isSuspendReconnectOnProtocolFailure

      public boolean isSuspendReconnectOnProtocolFailure()
      If this flag is true the reconnect will be suspended on protocol errors. Protocol errors are errors while SSL negotiation or when PING before connect fails.
      Returns:
      true if reconnect will be suspended on protocol errors.
    • getScriptCharset

      public Charset getScriptCharset()
      Returns the Lua script Charset.
      Returns:
      the script Charset.
      Since:
      6.0
    • getSocketOptions

      public SocketOptions getSocketOptions()
      Returns the SocketOptions.
      Returns:
      the SocketOptions.
    • getSslOptions

      public SslOptions getSslOptions()
      Returns the SslOptions.
      Returns:
      the SslOptions.
    • getTimeoutOptions

      public TimeoutOptions getTimeoutOptions()
      Returns the TimeoutOptions.
      Returns:
      the TimeoutOptions.
      Since:
      5.1