Package io.lettuce.core
Class ReadFrom
- java.lang.Object
-
- io.lettuce.core.ReadFrom
-
public abstract class ReadFrom extends Object
Defines from which Redis nodes data is read.- Since:
- 4.0
- Author:
- Mark Paluch, Ryosuke Hasebe, Omer Cilingir, Yohei Ueki
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ReadFrom.Nodes
Descriptor of nodes that are available for the current read operation.
-
Field Summary
Fields Modifier and Type Field Description static ReadFrom
ANY
Setting to read from any node.static ReadFrom
ANY_REPLICA
Setting to read from any replica node.static ReadFrom
LOWEST_LATENCY
Setting to read from the node with the lowest latency during topology discovery.static ReadFrom
MASTER
Setting to read from the upstream only.static ReadFrom
MASTER_PREFERRED
Setting to read preferred from the upstream and fall back to a replica if the master is not available.static ReadFrom
NEAREST
Deprecated.since 6.1.7 as we're renaming this setting toLOWEST_LATENCY
for more clarity what this setting actually represents.static ReadFrom
REPLICA
Setting to read from the replica only.static ReadFrom
REPLICA_PREFERRED
Setting to read preferred from replica and fall back to upstream if no replica is available.static ReadFrom
SLAVE
Deprecated.renamed toREPLICA
.static ReadFrom
SLAVE_PREFERRED
Deprecated.Renamed toREPLICA_PREFERRED
.static ReadFrom
UPSTREAM
Setting to read from the upstream only.static ReadFrom
UPSTREAM_PREFERRED
Setting to read preferred from the upstream and fall back to a replica if the upstream is not available.
-
Constructor Summary
Constructors Constructor Description ReadFrom()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean
isOrderSensitive()
static ReadFrom
regex(Pattern pattern)
Read from any node that hasRedisURI
matching with the given pattern.static ReadFrom
regex(Pattern pattern, boolean orderSensitive)
Read from any node that hasRedisURI
matching with the given pattern.abstract List<RedisNodeDescription>
select(ReadFrom.Nodes nodes)
Chooses the nodes from the matching Redis nodes that match this read selector.static ReadFrom
subnet(String... cidrNotations)
Setting to read from any node in the subnets.static ReadFrom
valueOf(String name)
Retrieve theReadFrom
preset by name.
-
-
-
Field Detail
-
MASTER
public static final ReadFrom MASTER
Setting to read from the upstream only.
-
MASTER_PREFERRED
public static final ReadFrom MASTER_PREFERRED
Setting to read preferred from the upstream and fall back to a replica if the master is not available.
-
UPSTREAM
public static final ReadFrom UPSTREAM
Setting to read from the upstream only.- Since:
- 6.0
-
UPSTREAM_PREFERRED
public static final ReadFrom UPSTREAM_PREFERRED
Setting to read preferred from the upstream and fall back to a replica if the upstream is not available.- Since:
- 6.0
-
REPLICA_PREFERRED
public static final ReadFrom REPLICA_PREFERRED
Setting to read preferred from replica and fall back to upstream if no replica is available.- Since:
- 5.2
-
SLAVE_PREFERRED
@Deprecated public static final ReadFrom SLAVE_PREFERRED
Deprecated.Renamed toREPLICA_PREFERRED
.Setting to read preferred from replicas and fall back to upstream if no replica is available.- Since:
- 4.4
-
REPLICA
public static final ReadFrom REPLICA
Setting to read from the replica only.- Since:
- 5.2
-
SLAVE
@Deprecated public static final ReadFrom SLAVE
Deprecated.renamed toREPLICA
.Setting to read from the replica only.
-
LOWEST_LATENCY
public static final ReadFrom LOWEST_LATENCY
Setting to read from the node with the lowest latency during topology discovery. Note that latency measurements are momentary snapshots that can change in rapid succession. Requires dynamic refresh sources to obtain topologies and latencies from all nodes in the cluster.- Since:
- 6.1.7
-
NEAREST
@Deprecated public static final ReadFrom NEAREST
Deprecated.since 6.1.7 as we're renaming this setting toLOWEST_LATENCY
for more clarity what this setting actually represents.Setting to read from the node with the lowest latency during topology discovery. Note that latency measurements are momentary snapshots that can change in rapid succession. Requires dynamic refresh sources to obtain topologies and latencies from all nodes in the cluster.
-
ANY
public static final ReadFrom ANY
Setting to read from any node.- Since:
- 5.2
-
ANY_REPLICA
public static final ReadFrom ANY_REPLICA
Setting to read from any replica node.- Since:
- 6.0.1
-
-
Method Detail
-
subnet
public static ReadFrom subnet(String... cidrNotations)
Setting to read from any node in the subnets.- Parameters:
cidrNotations
- CIDR-block notation strings, e.g., "192.168.0.0/16", "2001:db8:abcd:0000::/52". Must not benull
.- Returns:
- an instance of
ReadFromImpl.ReadFromSubnet
. - Since:
- 6.1
-
regex
public static ReadFrom regex(Pattern pattern)
Read from any node that hasRedisURI
matching with the given pattern.- Parameters:
pattern
- regex pattern, e.g.,Pattern.compile(".*region-1.*")
. Must not benull
.- Returns:
- an instance of
ReadFromImpl.ReadFromRegex
. - Since:
- 6.1
-
regex
public static ReadFrom regex(Pattern pattern, boolean orderSensitive)
Read from any node that hasRedisURI
matching with the given pattern.- Parameters:
pattern
- regex pattern, e.g.,Pattern.compile(".*region-1.*")
. Must not benull
.orderSensitive
-true
to attempt reads in the order of hosts returned byselect(Nodes)
;false
to apply randomization.- Returns:
- an instance of
ReadFromImpl.ReadFromRegex
. - Since:
- 6.1
-
select
public abstract List<RedisNodeDescription> select(ReadFrom.Nodes nodes)
Chooses the nodes from the matching Redis nodes that match this read selector.- Parameters:
nodes
- set of nodes that are suitable for reading- Returns:
- List of
RedisNodeDescription
s that are selected for reading
-
isOrderSensitive
protected boolean isOrderSensitive()
-
-