ClientOptions¶
ClientOptions allow controlling behavior for some specific features.
ClientOptions are immutable. Connections inherit the current options at the moment the connection is created. Changes to options will not affect existing connections.
client.setOptions(ClientOptions.builder()
.autoReconnect(false)
.pingBeforeActivateConnection(true)
.build());
| Name | Method | Default |
|---|---|---|
| PING before activating connection | pingBeforeActivateConnection |
true |
Since: 3.1, 4.0 Perform a lightweight Failed The |
||
| Auto-Reconnect | autoReconnect |
true |
Since: 3.1, 4.0 Controls auto-reconnect behavior on connections. As soon as a connection gets closed/reset without the intention to close it, the client will try to reconnect, activate the connection and re-issue any queued commands. This flag also has the effect that disconnected connections will refuse commands and cancel these with an exception. |
||
| Replay filter | replayFilter |
(cmd) -> false |
Since: 6.6 Controls which commands are to be filtered out in case the driver
attempts to reconnect to the server. Returning This flag has no effect in case the autoReconnect feature is not enabled. |
||
| Policy how to reclaim decode buffer memory | decodeBufferPolicy |
ratio-based at 75% |
Since: 6.0 Policy to discard read bytes from the decoding aggregation buffer to
reclaim memory. See |
||
| Suspend reconnect on protocol failure | suspendReconnectOnProtocolFailure |
false (was introduced in 3. 1 with default true) |
Since: 3.1, 4.0 If this flag is Reconnection can be activated again, but there is no public API to
obtain the |
||
| Request queue size | requestQueueSize |
2147483647 (Integer#MAX_VALUE) |
Since: 3.4, 4.1 Controls the per-connection request queue size. The command
invocation will lead to a |
||
| Disconnected behavior | disconnectedBehavior |
DEFAULT |
Since: 3.4, 4.1 A connection can behave in a disconnected state in various ways. The auto-connect feature allows in particular to retrigger commands that have been queued while a connection is disconnected. The disconnected behavior setting allows fine-grained control over the behavior. Following settings are available:
|
||
| Protocol Version | protocolVersion |
Latest/Auto-discovery |
Since: 6.0 Configuration of which protocol version (RESP2/RESP3) to use. Leaving this option unconfigured performs a protocol discovery to use the latest available protocol. |
||
| Script Charset | scriptCharset |
UTF-8 |
Since: 6.0 Charset to use for Lua scripts. |
||
| Socket Options | socketOptions |
10 seconds Connection-Timeout, no keep-alive, no TCP noDelay |
Since: 4.3 Options to configure low-level socket options for the connections kept to Redis servers. |
||
| SSL Options | sslOptions |
(none), use JDK defaults |
Since: 4.3 Configure SSL options regarding SSL providers (JDK/OpenSSL) and key store/trust store. |
||
| Timeout Options | timeoutOptions |
Do not timeout commands. |
Since: 5.1 Options to configure command timeouts applied to timeout commands
after dispatching these (active connections, queued while disconnected,
batch buffer). By default, the synchronous API times out commands using
|
||
| Publish Reactive Signals on Scheduler | publishOnScheduler |
Use I/O thread. |
Since: 5.1.4 Use a dedicated |
||
Cluster-specific options¶
ClusterClientOptions extend the regular ClientOptions by some cluster specifics.
ClusterClientOptions are immutable. Connections inherit the current options at the moment the connection is created. Changes to options will not affect existing connections.
ClusterTopologyRefreshOptions topologyRefreshOptions = ClusterTopologyRefreshOptions.builder()
.enablePeriodicRefresh(refreshPeriod(10, TimeUnit.MINUTES))
.enableAllAdaptiveRefreshTriggers()
.build();
client.setOptions(ClusterClientOptions.builder()
.topologyRefreshOptions(topologyRefreshOptions)
.build());
| Name | Method | Default |
|---|---|---|
| Periodic cluster topology refresh | enablePeriodicRefresh |
false |
Since: 3.1, 4.0 Enables or disables periodic cluster topology refresh. The refresh is
handled in the background. Partitions, the view on the Redis cluster
topology, are valid for a whole The refresh job is regularly executed, the period between the runs
can be set with |
||
| Cluster topology refresh period | refreshPeriod |
60 SECONDS |
Since: 3.1, 4.0 Set the period between the refresh job runs. The effective interval cannot be changed once the refresh job is active. Changes to the value will be ignored. |
||
| Adaptive cluster topology refresh | enableAdaptiveRefreshTrigger |
(none) |
Since: 4.2 Enables selectively adaptive topology refresh triggers. Adaptive refresh triggers initiate topology view updates based on events happened during Redis Cluster operations. Adaptive triggers lead to an immediate topology refresh. These refreshes are rate-limited using a timeout since events can happen on a large scale. Adaptive refresh triggers are disabled by default. Following triggers can be enabled:
|
||
| Adaptive refresh triggers timeout | adaptiveRefreshTriggersTimeout |
30 SECONDS |
Since: 4.2 Set the timeout between the adaptive refresh job runs. Multiple triggers within the timeout will be ignored, only the first enabled trigger leads to a topology refresh. The effective period cannot be changed once the refresh job is active. Changes to the value will be ignored. |
||
| Reconnect attempts (Adaptive topology refresh trigger) | refreshTriggersReconnectAttempts |
5 |
Since: 4.2 Set the threshold for the |
||
| Dynamic topology refresh sources | dynamicRefreshSources |
true |
Since: 4.2 Discover cluster nodes from the topology and use only the discovered
nodes as the source for the cluster topology. Using dynamic refresh will
query all discovered nodes for the cluster topology details. If set to
Note that enabling dynamic topology refresh sources uses node
addresses reported by Redis |
||
| Close stale connections | closeStaleConnections |
true |
Since: 3.3, 4.1 Stale connections are existing connections to nodes which are no
longer part of the Redis Cluster. If this flag is set to
|
||
| Limitation of cluster redirects | maxRedirects |
5 |
Since: 3.1, 4.0 When the assignment of a slot-hash is moved in a Redis Cluster and a
client requests a key that is located on the moved slot-hash, the
Cluster node responds with a |
||
| Filter nodes from Topology | nodeFilter |
no filter |
Since: 6.1.6 When providing a |
||
| Validate cluster node membership | validateClusterNodeMembership |
true |
Since: 3.3, 4.0 Validate the cluster node membership before allowing connections to
that node. The current implementation performs redirects using
There are some scenarios, where the strict validation is an obstruction:
Connecting to non-cluster members to reconfigure those while using the RedisClusterClient connection. |
||
Request queue size and cluster¶
Clustered operations use multiple connections. The resulting
overall-queue limit is
requestQueueSize * ((number of cluster nodes * 2) + 1).