K - Key type.V - Value type.public interface StatefulRedisClusterConnection<K,V> extends StatefulConnection<K,V>
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(RedisClusterPushListener listener)
Add a new
listener to consume push messages. |
RedisAdvancedClusterAsyncCommands<K,V> |
async()
Returns the
RedisAdvancedClusterAsyncCommands API for the current connection. |
RedisChannelWriter |
getChannelWriter() |
default StatefulRedisConnection<K,V> |
getConnection(String nodeId)
Retrieve a connection to the specified cluster node using the
nodeId suitable for write operations. |
StatefulRedisConnection<K,V> |
getConnection(String nodeId,
ConnectionIntent connectionIntent)
Retrieve a connection to the specified cluster node using the
nodeId for the given ConnectionIntent. |
default StatefulRedisConnection<K,V> |
getConnection(String host,
int port)
Retrieve a connection to the specified cluster node using host and port suitable for
write
operations. |
StatefulRedisConnection<K,V> |
getConnection(String host,
int port,
ConnectionIntent connectionIntent)
Retrieve a connection to the specified cluster node using host and port.
|
default CompletableFuture<StatefulRedisConnection<K,V>> |
getConnectionAsync(String nodeId)
Retrieve asynchronously a connection to the specified cluster node using the
nodeId suitable for
write operations. |
CompletableFuture<StatefulRedisConnection<K,V>> |
getConnectionAsync(String nodeId,
ConnectionIntent connectionIntent)
Retrieve asynchronously a connection to the specified cluster node using the
nodeId for the given
ConnectionIntent. |
default CompletableFuture<StatefulRedisConnection<K,V>> |
getConnectionAsync(String host,
int port)
Retrieve asynchronously a connection to the specified cluster node using host and port suitable for
write operations. |
CompletableFuture<StatefulRedisConnection<K,V>> |
getConnectionAsync(String host,
int port,
ConnectionIntent connectionIntent)
Retrieve asynchronously a connection to the specified cluster node using host and port for the given
ConnectionIntent. |
Partitions |
getPartitions() |
ReadFrom |
getReadFrom()
Gets the
ReadFrom setting for this connection. |
RedisAdvancedClusterReactiveCommands<K,V> |
reactive()
Returns the
RedisAdvancedClusterReactiveCommands API for the current connection. |
void |
removeListener(RedisClusterPushListener listener)
Remove an existing
listener. |
void |
setReadFrom(ReadFrom readFrom)
Set from which nodes data is read.
|
RedisAdvancedClusterCommands<K,V> |
sync()
Returns the
RedisAdvancedClusterCommands API for the current connection. |
addListener, close, closeAsync, dispatch, dispatch, flushCommands, getCodec, getOptions, getResources, getTimeout, isOpen, removeListener, setAutoFlushCommands, setTimeoutRedisAdvancedClusterCommands<K,V> sync()
RedisAdvancedClusterCommands API for the current connection. Does not create a new connection.RedisAdvancedClusterAsyncCommands<K,V> async()
RedisAdvancedClusterAsyncCommands API for the current connection. Does not create a new connection.RedisAdvancedClusterReactiveCommands<K,V> reactive()
RedisAdvancedClusterReactiveCommands API for the current connection. Does not create a new
connection.default StatefulRedisConnection<K,V> getConnection(String nodeId)
nodeId suitable for write operations. Host and port are looked up in the node list. This connection is bound to the node id. Once the
cluster topology view is updated, the connection will try to reconnect the to the node with the specified nodeId,
that behavior can also lead to a closed connection once the node with the specified nodeId is no longer part of
the cluster.
Do not close the connections. Otherwise, unpredictable behavior will occur. The nodeId must be part of the cluster and is
validated against the current topology view in Partitions.
Calling this method is equivalent to calling getConnection(String, ConnectionIntent) with the
connectionIntent parameter set to ConnectionIntent.WRITE
In contrast to the StatefulRedisClusterConnection, node-connections do not route commands to other cluster nodes.
nodeId - the node IdRedisException - if the requested node identified by nodeId is not part of the clusterStatefulRedisConnection<K,V> getConnection(String nodeId, ConnectionIntent connectionIntent)
nodeId for the given ConnectionIntent. Host
and port are looked up in the node list. This connection is bound to the node id. Once the cluster topology view is
updated, the connection will try to reconnect the to the node with the specified nodeId, that behavior can also
lead to a closed connection once the node with the specified nodeId is no longer part of the cluster.
Do not close the connections. Otherwise, unpredictable behavior will occur. The nodeId must be part of the cluster and is
validated against the current topology view in Partitions.
This method is intended to be used for cases where the caller requires a specific connection type (READ or WRITE) to a given node in a cluster.
In contrast to the StatefulRedisClusterConnection, node-connections do not route commands to other cluster nodes.
nodeId - the node IdconnectionIntent - the intent for usage of the connection.RedisException - if the requested node identified by nodeId is not part of the clusterdefault CompletableFuture<StatefulRedisConnection<K,V>> getConnectionAsync(String nodeId)
nodeId suitable for
write operations. Host and port are looked up in the node list. This connection is bound
to the node id. Once the cluster topology view is updated, the connection will try to reconnect the to the node with the
specified nodeId, that behavior can also lead to a closed connection once the node with the specified
nodeId is no longer part of the cluster.
Do not close the connections. Otherwise, unpredictable behavior will occur. The nodeId must be part of the cluster and is
validated against the current topology view in Partitions.
Calling this method is equivalent to calling getConnectionAsync(String, ConnectionIntent) with the
connectionIntent parameter set to ConnectionIntent.WRITE
In contrast to the StatefulRedisClusterConnection, node-connections do not route commands to other cluster nodes.
nodeId - the node IdCompletableFuture to indicate success or failure to connect to the requested cluster node.RedisException - if the requested node identified by nodeId is not part of the clusterCompletableFuture<StatefulRedisConnection<K,V>> getConnectionAsync(String nodeId, ConnectionIntent connectionIntent)
nodeId for the given
ConnectionIntent. Host and port are looked up in the node list. This connection is bound to the node id. Once the
cluster topology view is updated, the connection will try to reconnect the to the node with the specified nodeId,
that behavior can also lead to a closed connection once the node with the specified nodeId is no longer part of
the cluster.
Do not close the connections. Otherwise, unpredictable behavior will occur. The nodeId must be part of the cluster and is
validated against the current topology view in Partitions.
This method is intended to be used for cases where the caller requires a specific connection type (READ or WRITE) to a given node in a cluster.
In contrast to the StatefulRedisClusterConnection, node-connections do not route commands to other cluster nodes.
nodeId - the node IdconnectionIntent - the intent for usage of the connection.CompletableFuture to indicate success or failure to connect to the requested cluster node.RedisException - if the requested node identified by nodeId is not part of the clusterdefault StatefulRedisConnection<K,V> getConnection(String host, int port)
write
operations. This connection is bound to a host and port. Updates to the cluster topology view can close the connection
once the host, identified by host and port, are no longer part of the cluster.
Do not close the connections. Otherwise, unpredictable behavior will occur. Host and port connections are verified by
default for cluster membership, see ClusterClientOptions.isValidateClusterNodeMembership().
Calling this method is equivalent to calling getConnection(String, int, ConnectionIntent) with the
connectionIntent parameter set to ConnectionIntent.WRITE
In contrast to the StatefulRedisClusterConnection, node-connections do not route commands to other cluster nodes.
host - the hostport - the portRedisException - if the requested node identified by host and port is not part of the clusterStatefulRedisConnection<K,V> getConnection(String host, int port, ConnectionIntent connectionIntent)
host and port,
are no longer part of the cluster.
Do not close the connections. Otherwise, unpredictable behavior will occur. Host and port connections are verified by
default for cluster membership, see ClusterClientOptions.isValidateClusterNodeMembership().
In contrast to the StatefulRedisClusterConnection, node-connections do not route commands to other cluster nodes.
host - the hostport - the portconnectionIntent - the intent of the connection see getConnection(String, ConnectionIntent)RedisException - if the requested node identified by host and port is not part of the clusterdefault CompletableFuture<StatefulRedisConnection<K,V>> getConnectionAsync(String host, int port)
write operations. This connection is bound to a host and port. Updates to the cluster
topology view can close the connection once the host, identified by host and port, are no longer part of
the cluster.
Do not close the connections. Otherwise, unpredictable behavior will occur. Host and port connections are verified by
default for cluster membership, see ClusterClientOptions.isValidateClusterNodeMembership().
Calling this method is equivalent to calling getConnectionAsync(String, int, ConnectionIntent) with the
connectionIntent parameter set to ConnectionIntent.WRITE
In contrast to the StatefulRedisClusterConnection, node-connections do not route commands to other cluster nodes.
host - the hostport - the portCompletableFuture to indicate success or failure to connect to the requested cluster node.RedisException - if the requested node identified by host and port is not part of the clusterCompletableFuture<StatefulRedisConnection<K,V>> getConnectionAsync(String host, int port, ConnectionIntent connectionIntent)
ConnectionIntent. This connection is bound to a host and port. Updates to the cluster topology view can close the
connection once the host, identified by host and port, are no longer part of the cluster.
Do not close the connections. Otherwise, unpredictable behavior will occur. Host and port connections are verified by
default for cluster membership, see ClusterClientOptions.isValidateClusterNodeMembership().
In contrast to the StatefulRedisClusterConnection, node-connections do not route commands to other cluster nodes.
host - the hostport - the portconnectionIntent - the intent of the connection see getConnection(String, ConnectionIntent)CompletableFuture to indicate success or failure to connect to the requested cluster node.RedisException - if the requested node identified by host and port is not part of the clustervoid setReadFrom(ReadFrom readFrom)
ReadFrom for more information.readFrom - the read from setting, must not be nullReadFrom getReadFrom()
ReadFrom setting for this connection. Defaults to ReadFrom.UPSTREAM if not set.Partitions getPartitions()
RedisChannelWriter getChannelWriter()
RedisChannelWriter.void addListener(RedisClusterPushListener listener)
listener to consume push messages.listener - the listener, must not be null.void removeListener(RedisClusterPushListener listener)
listener.listener - the listener, must not be null.Copyright © 2025 lettuce.io. All rights reserved.