Package io.lettuce.core
Class SocketOptions
- java.lang.Object
-
- io.lettuce.core.SocketOptions
-
public class SocketOptions extends Object
Options to configure low-level socket options for the connections kept to Redis servers.- Since:
- 4.3
- Author:
- Mark Paluch, Bodong Ybd
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SocketOptions.Builder
Builder forSocketOptions
.static class
SocketOptions.KeepAliveOptions
Extended Keep-Alive options (idle, interval, count).static class
SocketOptions.TcpUserTimeoutOptions
TCP_USER_TIMEOUT comes from RFC5482 , configuring this parameter can allow the user TCP to initiate a reconnection to solve this problem when the network is abnormal.
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_CONNECT_TIMEOUT
static Duration
DEFAULT_CONNECT_TIMEOUT_DURATION
static TimeUnit
DEFAULT_CONNECT_TIMEOUT_UNIT
static boolean
DEFAULT_SO_KEEPALIVE
static boolean
DEFAULT_SO_NO_DELAY
static boolean
DEFAULT_TCP_USER_TIMEOUT_ENABLED
-
Constructor Summary
Constructors Modifier Constructor Description protected
SocketOptions(SocketOptions original)
protected
SocketOptions(SocketOptions.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SocketOptions.Builder
builder()
Returns a newSocketOptions.Builder
to constructSocketOptions
.static SocketOptions
copyOf(SocketOptions options)
Create a copy of optionsstatic SocketOptions
create()
Create a newSocketOptions
using default settings.Duration
getConnectTimeout()
Returns the connection timeout.SocketOptions.KeepAliveOptions
getKeepAlive()
Returns the TCP keepalive options.SocketOptions.TcpUserTimeoutOptions
getTcpUserTimeout()
boolean
isEnableTcpUserTimeout()
boolean
isKeepAlive()
Returns whether to enable TCP keepalive.boolean
isTcpNoDelay()
Returns whether to use TCP NoDelay.SocketOptions.Builder
mutate()
Returns a builder to create newSocketOptions
whose settings are replicated from the currentSocketOptions
.
-
-
-
Field Detail
-
DEFAULT_CONNECT_TIMEOUT
public static final long DEFAULT_CONNECT_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_CONNECT_TIMEOUT_UNIT
public static final TimeUnit DEFAULT_CONNECT_TIMEOUT_UNIT
-
DEFAULT_CONNECT_TIMEOUT_DURATION
public static final Duration DEFAULT_CONNECT_TIMEOUT_DURATION
-
DEFAULT_SO_KEEPALIVE
public static final boolean DEFAULT_SO_KEEPALIVE
- See Also:
- Constant Field Values
-
DEFAULT_TCP_USER_TIMEOUT_ENABLED
public static final boolean DEFAULT_TCP_USER_TIMEOUT_ENABLED
- See Also:
- Constant Field Values
-
DEFAULT_SO_NO_DELAY
public static final boolean DEFAULT_SO_NO_DELAY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SocketOptions
protected SocketOptions(SocketOptions.Builder builder)
-
SocketOptions
protected SocketOptions(SocketOptions original)
-
-
Method Detail
-
copyOf
public static SocketOptions copyOf(SocketOptions options)
Create a copy of options- Parameters:
options
- the original- Returns:
- A new instance of
SocketOptions
containing the values of options
-
builder
public static SocketOptions.Builder builder()
Returns a newSocketOptions.Builder
to constructSocketOptions
.- Returns:
- a new
SocketOptions.Builder
to constructSocketOptions
.
-
create
public static SocketOptions create()
Create a newSocketOptions
using default settings.- Returns:
- a new instance of default cluster client client options.
-
mutate
public SocketOptions.Builder mutate()
Returns a builder to create newSocketOptions
whose settings are replicated from the currentSocketOptions
.- Returns:
- a
SocketOptions.Builder
to create newSocketOptions
whose settings are replicated from the currentSocketOptions
- Since:
- 5.3
-
getConnectTimeout
public Duration getConnectTimeout()
Returns the connection timeout.- Returns:
- the connection timeout.
-
isKeepAlive
public boolean isKeepAlive()
Returns whether to enable TCP keepalive.- Returns:
- whether to enable TCP keepalive
- See Also:
SocketOptions.SO_KEEPALIVE
-
getKeepAlive
public SocketOptions.KeepAliveOptions getKeepAlive()
Returns the TCP keepalive options.- Returns:
- TCP keepalive options
- See Also:
SocketOptions.KeepAliveOptions
-
isTcpNoDelay
public boolean isTcpNoDelay()
Returns whether to use TCP NoDelay.- Returns:
true
to disable Nagle's algorithm,false
to enable Nagle's algorithm.- See Also:
SocketOptions.TCP_NODELAY
-
isEnableTcpUserTimeout
public boolean isEnableTcpUserTimeout()
-
getTcpUserTimeout
public SocketOptions.TcpUserTimeoutOptions getTcpUserTimeout()
-
-