Package io.vertx.redis.client
Interface RedisCluster
-
public interface RedisCluster
Utilities for Redis cluster. Callingcreate()
with an instance ofRedis
orRedisConnection
that are not Redis cluster client/connection leads to an exception.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static RedisCluster
create(Redis client)
static RedisCluster
create(RedisConnection connection)
Future<RequestGrouping>
groupByNodes(List<Request> requests)
Groups therequests
into aRequestGrouping
, which contains: keyed requests: requests that include a key and it is therefore possible to determine to which master node they should be sent; all requests in each inner list in thekeyed
collection are guaranteed to be sent to the same master node; unkeyed requests: requests that do not include a key and it is therefore not possible to determine to which master node they should be sent. If any of therequests
includes multiple keys that belong to different master nodes, the resulting future will fail.Future<List<Response>>
onAllMasterNodes(Request request)
Runs therequest
against all master nodes in the cluster.Future<List<Response>>
onAllNodes(Request request)
Runs therequest
against all nodes in the cluster.
-
-
-
Method Detail
-
create
static RedisCluster create(Redis client)
-
create
static RedisCluster create(RedisConnection connection)
-
onAllNodes
Future<List<Response>> onAllNodes(Request request)
Runs therequest
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.- Parameters:
request
- the request, must not benull
- Returns:
- the future result, never
null
-
onAllMasterNodes
Future<List<Response>> onAllMasterNodes(Request request)
Runs therequest
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.- Parameters:
request
- the request, must not benull
- Returns:
- the future result, never
null
-
groupByNodes
Future<RequestGrouping> groupByNodes(List<Request> requests)
Groups therequests
into aRequestGrouping
, which contains:- keyed requests: requests that include a key and it is therefore possible
to determine to which master node they should be sent; all requests in each inner list
in the
keyed
collection are guaranteed to be sent to the same master node; - unkeyed requests: requests that do not include a key and it is therefore not possible to determine to which master node they should be sent.
requests
includes multiple keys that belong to different master nodes, the resulting future will fail.If the cluster client was created with
RedisReplicas.SHARE
orRedisReplicas.ALWAYS
and the commands are executed individually (usingsend()
, notbatch()
), it is possible that the commands will be spread across different replicas of the same master node.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.
- Parameters:
requests
- the requests, must not benull
- Returns:
- the requests grouped by the cluster node assignment
- keyed requests: requests that include a key and it is therefore possible
to determine to which master node they should be sent; all requests in each inner list
in the
-
-