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 interfaceReadFrom.NodesDescriptor of nodes that are available for the current read operation. -
Field Summary
Fields Modifier and Type Field Description static ReadFromANYSetting to read from any node.static ReadFromANY_REPLICASetting to read from any replica node.static ReadFromMASTERSetting to read from the upstream only.static ReadFromMASTER_PREFERREDSetting to read preferred from the upstream and fall back to a replica if the master is not available.static ReadFromNEARESTSetting to read from the nearest node.static ReadFromREPLICASetting to read from the replica only.static ReadFromREPLICA_PREFERREDSetting to read preferred from replica and fall back to upstream if no replica is not available.static ReadFromSLAVEDeprecated.static ReadFromSLAVE_PREFERREDDeprecated.Renamed toREPLICA_PREFERRED.static ReadFromUPSTREAMSetting to read from the upstream only.static ReadFromUPSTREAM_PREFERREDSetting 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
Modifier and Type Method Description protected booleanisOrderSensitive()static ReadFromregex(Pattern pattern)Read from any node that hasRedisURImatching with the given pattern.static ReadFromregex(Pattern pattern, boolean orderSensitive)Read from any node that hasRedisURImatching 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 ReadFromsubnet(String... cidrNotations)Setting to read from any node in the subnets.static ReadFromvalueOf(String name)Retrieve theReadFrompreset by name.
-
Field Details
-
MASTER
Setting to read from the upstream only. -
MASTER_PREFERRED
Setting to read preferred from the upstream and fall back to a replica if the master is not available. -
UPSTREAM
Setting to read from the upstream only.- Since:
- 6.0
-
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
Setting to read preferred from replica and fall back to upstream if no replica is not available.- Since:
- 5.2
-
SLAVE_PREFERRED
Deprecated.Renamed toREPLICA_PREFERRED.Setting to read preferred from replicas and fall back to upstream if no replica is not available.- Since:
- 4.4
-
REPLICA
Setting to read from the replica only.- Since:
- 5.2
-
SLAVE
Deprecated.renamed toREPLICA.Setting to read from the replica only. -
NEAREST
Setting to read from the nearest node. -
ANY
Setting to read from any node.- Since:
- 5.2
-
ANY_REPLICA
Setting to read from any replica node.- Since:
- 6.0.1
-
-
Constructor Details
-
ReadFrom
public ReadFrom()
-
-
Method Details
-
subnet
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
Read from any node that hasRedisURImatching 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
Read from any node that hasRedisURImatching with the given pattern.- Parameters:
pattern- regex pattern, e.g.,Pattern.compile(".*region-1.*"). Must not benull.orderSensitive-trueto attempt reads in the order of hosts returned byselect(Nodes);falseto apply randomization.- Returns:
- an instance of
ReadFromImpl.ReadFromRegex. - Since:
- 6.1
-
select
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
RedisNodeDescriptions that are selected for reading
-
isOrderSensitive
protected boolean isOrderSensitive() -
valueOf
Retrieve theReadFrompreset by name.- Parameters:
name- the name of the read from setting- Returns:
- the
ReadFrompreset - Throws:
IllegalArgumentException- ifnameis empty,nullor theReadFrompreset is unknown.
-
REPLICA.