public interface RedisCluster
create() with an instance of Redis
or RedisConnection that are not Redis cluster client/connection leads to
an exception.| Modifier and Type | Method and Description |
|---|---|
static RedisCluster |
create(Redis client) |
static RedisCluster |
create(RedisConnection connection) |
Future<List<List<Request>>> |
groupByNodes(List<Request> requests)
Groups the
requests such that all requests in each inner list in the result
are guaranteed to be sent to the same Redis master node. |
Future<List<Response>> |
onAllMasterNodes(Request request)
Runs the
request against all master nodes in the cluster. |
Future<List<Response>> |
onAllNodes(Request request)
Runs the
request against all nodes in the cluster. |
static RedisCluster create(Redis client)
static RedisCluster create(RedisConnection connection)
Future<List<Response>> onAllNodes(Request request)
request against all nodes in the cluster.
Returns a future that completes with a list of responses, one from each
node, or failure when one of the operations fails. Note that in case
of a failure, there are no guarantees that the request was or wasn't
executed successfully on other Redis cluster nodes. No result order
is guaranteed either.request - the request, must not be nullnullFuture<List<Response>> onAllMasterNodes(Request request)
request against all master nodes in the cluster.
Returns a future that completes with a list of responses, one from each
master node, or failure when one of the operations fails. Note that in case
of a failure, there are no guarantees that the request was or wasn't
executed successfully on other Redis cluster master nodes. No result order
is guaranteed either.request - the request, must not be nullnullFuture<List<List<Request>>> groupByNodes(List<Request> requests)
requests such that all requests in each inner list in the result
are guaranteed to be sent to the same Redis master node.
If the cluster client was not created with RedisReplicas.NEVER and
the commands are executed individually (not using batch()),
it is possible that the commands will be spread across different replicas
of the same master node.
If any of the requests don't have keys and hence are targeted at a random
node, all such requests shall be grouped into an extra single list for which
the above guarantee does not apply. If any of the requests includes multiple
keys that belong to different master nodes, the resulting future will fail.
Note that this method is only reliable in case the Redis cluster is in a stable state. In case of resharding, failover or in general any change of cluster topology, there are no guarantees on the validity of the result.
requests - the requests, must not be nullCopyright © 2025 Eclipse. All rights reserved.