public class LettuceClusterConnection extends LettuceConnection implements DefaultedRedisClusterConnection
Modifier and Type | Class and Description |
---|---|
protected static interface |
LettuceClusterConnection.LettuceClusterCommandCallback<T>
Lettuce specific implementation of
ClusterCommandExecutor.ClusterCommandCallback . |
protected static interface |
LettuceClusterConnection.LettuceMultiKeyClusterCommandCallback<T>
Lettuce specific implementation of
ClusterCommandExecutor.MultiKeyClusterCommandCallback . |
RedisClusterCommands.AddSlots
RedisStringCommands.BitOperation, RedisStringCommands.SetOption
RedisListCommands.Position
RedisZSetCommands.Aggregate, RedisZSetCommands.Limit, RedisZSetCommands.Range, RedisZSetCommands.Tuple
RedisGeoCommands.DistanceUnit, RedisGeoCommands.GeoLocation<T>, RedisGeoCommands.GeoRadiusCommandArgs
Constructor and Description |
---|
LettuceClusterConnection(io.lettuce.core.cluster.RedisClusterClient clusterClient)
Creates new
LettuceClusterConnection using RedisClusterClient . |
LettuceClusterConnection(io.lettuce.core.cluster.RedisClusterClient clusterClient,
ClusterCommandExecutor executor)
Creates new
LettuceClusterConnection using RedisClusterClient running commands across the cluster
via given ClusterCommandExecutor . |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes (or quits) the connection.
|
void |
clusterAddSlots(RedisClusterNode node,
int... slots)
Assign slots to given
RedisClusterNode . |
void |
clusterAddSlots(RedisClusterNode node,
RedisClusterNode.SlotRange range)
Assign
RedisClusterNode.SlotRange.getSlotsArray() to given RedisClusterNode . |
Long |
clusterCountKeysInSlot(int slot)
Count the number of keys assigned to one slot.
|
void |
clusterDeleteSlots(RedisClusterNode node,
int... slots)
Remove slots from
RedisClusterNode . |
void |
clusterDeleteSlotsInRange(RedisClusterNode node,
RedisClusterNode.SlotRange range)
Removes
RedisClusterNode.SlotRange.getSlotsArray() from given RedisClusterNode . |
void |
clusterForget(RedisClusterNode node)
Remove given node from cluster.
|
ClusterInfo |
clusterGetClusterInfo()
Get cluster information.
|
List<byte[]> |
clusterGetKeysInSlot(int slot,
Integer count)
Get keys served by slot.
|
Map<RedisClusterNode,Collection<RedisClusterNode>> |
clusterGetMasterSlaveMap()
Retrieve information about masters and their connected slaves.
|
RedisClusterNode |
clusterGetNodeForKey(byte[] key)
Find the
RedisClusterNode serving given key. |
RedisClusterNode |
clusterGetNodeForSlot(int slot)
Find the
RedisClusterNode serving given slot. |
List<RedisClusterNode> |
clusterGetNodes()
Retrieve cluster node information such as id, host, port and slots.
|
Set<RedisClusterNode> |
clusterGetSlaves(RedisClusterNode master)
Retrieve information about connected slaves for given master node.
|
Integer |
clusterGetSlotForKey(byte[] key)
Find the slot for a given
key . |
void |
clusterMeet(RedisClusterNode node)
Add given node to cluster.
|
void |
clusterReplicate(RedisClusterNode master,
RedisClusterNode slave)
Assign a slave to given master.
|
void |
clusterSetSlot(RedisClusterNode node,
int slot,
RedisClusterCommands.AddSlots mode) |
protected io.lettuce.core.api.StatefulConnection<byte[],byte[]> |
doGetAsyncDedicatedConnection() |
RedisGeoCommands |
geoCommands()
Get
RedisGeoCommands . |
ClusterCommandExecutor |
getClusterCommandExecutor() |
RedisHashCommands |
hashCommands()
Get
RedisHashCommands . |
RedisHyperLogLogCommands |
hyperLogLogCommands()
|
RedisKeyCommands |
keyCommands()
Get
RedisKeyCommands . |
Set<byte[]> |
keys(RedisClusterNode node,
byte[] pattern) |
RedisListCommands |
listCommands()
Get
RedisListCommands . |
void |
multi()
Mark the start of a transaction block.
|
String |
ping()
Test connection.
|
String |
ping(RedisClusterNode node) |
byte[] |
randomKey(RedisClusterNode node) |
void |
select(int dbIndex)
Select the DB with given positive
dbIndex . |
RedisClusterServerCommands |
serverCommands()
Get
RedisServerCommands . |
RedisSetCommands |
setCommands()
Get
RedisSetCommands . |
RedisStringCommands |
stringCommands()
Get
RedisStringCommands . |
protected io.lettuce.core.pubsub.StatefulRedisPubSubConnection<byte[],byte[]> |
switchToPubSub()
LettuceConnection.close() the current connection and open a new pub/sub connection to the Redis server. |
void |
unwatch()
Flushes all the previously
#watch(byte[]...) keys. |
void |
watch(byte[]... keys)
Watch given
keys for modifications during transaction started with RedisTxCommands.multi() . |
RedisZSetCommands |
zSetCommands()
Get
RedisZSetCommands . |
closePipeline, convertLettuceAccessException, discard, echo, exec, execute, execute, getAsyncDedicatedConnection, getConnection, getNativeConnection, getSentinelConnection, getSubscription, isActive, isClosed, isPipelined, isQueueing, isSubscribed, openPipeline, pSubscribe, publish, scriptingCommands, setConvertPipelineAndTxResults, subscribe
getSentinelConnection, hasRedisSentinelConfigured, setSentinelConfiguration
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
bgReWriteAof, bgSave, dbSize, flushAll, flushDb, getClientList, getConfig, info, info, lastSave, resetConfigStats, save, setConfig, shutdown, time
append, bgReWriteAof, bgSave, bgWriteAof, bitCount, bitCount, bitOp, bLPop, bRPop, bRPopLPush, dbSize, decr, decrBy, del, dump, eval, evalSha, evalSha, exists, expire, expireAt, flushAll, flushDb, geoAdd, geoAdd, geoAdd, geoDist, geoDist, geoHash, geoPos, geoRadius, geoRadius, geoRadiusByMember, geoRadiusByMember, geoRemove, get, getBit, getClientList, getClientName, getConfig, getRange, getSet, hDel, hExists, hGet, hGetAll, hIncrBy, hIncrBy, hKeys, hLen, hMGet, hMSet, hScan, hSet, hSetNX, hVals, incr, incrBy, incrBy, info, info, keys, killClient, lastSave, lIndex, lInsert, lLen, lPop, lPush, lPushX, lRange, lRem, lSet, lTrim, mGet, migrate, migrate, move, mSet, mSetNX, persist, pExpire, pExpireAt, pfAdd, pfCount, pfMerge, pSetEx, pTtl, pTtl, randomKey, rename, renameNX, resetConfigStats, restore, rPop, rPopLPush, rPush, rPushX, sAdd, save, scan, sCard, scriptExists, scriptFlush, scriptKill, scriptLoad, sDiff, sDiffStore, set, set, setBit, setClientName, setConfig, setEx, setNX, setRange, shutdown, shutdown, sInter, sInterStore, sIsMember, slaveOf, slaveOfNoOne, sMembers, sMove, sort, sort, sPop, sRandMember, sRandMember, sRem, sScan, strLen, sUnion, sUnionStore, time, ttl, ttl, type, zAdd, zAdd, zCard, zCount, zCount, zIncrBy, zInterStore, zInterStore, zRange, zRangeByLex, zRangeByScore, zRangeByScore, zRangeByScore, zRangeByScoreWithScores, zRangeWithScores, zRank, zRem, zRemRange, zRemRangeByScore, zRemRangeByScore, zRevRange, zRevRangeByScore, zRevRangeByScoreWithScores, zRevRangeWithScores, zRevRank, zScan, zScore, zUnionStore, zUnionStore
closePipeline, getNativeConnection, getSentinelConnection, isClosed, isPipelined, isQueueing, openPipeline, scriptingCommands
execute
zRangeByLex, zRangeByLex, zRangeByScore, zRangeByScore, zRangeByScore, zRangeByScoreWithScores, zRangeByScoreWithScores, zRangeByScoreWithScores, zRevRangeByScore, zRevRangeByScore, zRevRangeByScore, zRevRangeByScoreWithScores, zRevRangeByScoreWithScores, zRevRangeByScoreWithScores
discard, exec
getSubscription, isSubscribed, pSubscribe, publish, subscribe
echo
geoAdd, geoRadiusByMember
public LettuceClusterConnection(io.lettuce.core.cluster.RedisClusterClient clusterClient)
LettuceClusterConnection
using RedisClusterClient
.clusterClient
- must not be null.public LettuceClusterConnection(io.lettuce.core.cluster.RedisClusterClient clusterClient, ClusterCommandExecutor executor)
LettuceClusterConnection
using RedisClusterClient
running commands across the cluster
via given ClusterCommandExecutor
.clusterClient
- must not be null.executor
- must not be null.public RedisGeoCommands geoCommands()
RedisConnection
RedisGeoCommands
.geoCommands
in interface RedisConnection
geoCommands
in class LettuceConnection
public RedisHashCommands hashCommands()
RedisConnection
RedisHashCommands
.hashCommands
in interface RedisConnection
hashCommands
in class LettuceConnection
public RedisHyperLogLogCommands hyperLogLogCommands()
RedisConnection
hyperLogLogCommands
in interface RedisConnection
hyperLogLogCommands
in class LettuceConnection
public RedisKeyCommands keyCommands()
RedisConnection
RedisKeyCommands
.keyCommands
in interface RedisConnection
keyCommands
in class LettuceConnection
public RedisListCommands listCommands()
RedisConnection
RedisListCommands
.listCommands
in interface RedisConnection
listCommands
in class LettuceConnection
public RedisStringCommands stringCommands()
RedisConnection
RedisStringCommands
.stringCommands
in interface RedisConnection
stringCommands
in class LettuceConnection
public RedisSetCommands setCommands()
RedisConnection
RedisSetCommands
.setCommands
in interface RedisConnection
setCommands
in class LettuceConnection
public RedisZSetCommands zSetCommands()
RedisConnection
RedisZSetCommands
.zSetCommands
in interface RedisConnection
zSetCommands
in class LettuceConnection
public RedisClusterServerCommands serverCommands()
RedisConnection
RedisServerCommands
.serverCommands
in interface RedisClusterConnection
serverCommands
in interface RedisConnection
serverCommands
in class LettuceConnection
public Set<RedisClusterNode> clusterGetSlaves(RedisClusterNode master)
RedisClusterCommands
clusterGetSlaves
in interface RedisClusterCommands
master
- must not be null.public Integer clusterGetSlotForKey(byte[] key)
RedisClusterCommands
key
.clusterGetSlotForKey
in interface RedisClusterCommands
key
- must not be null.public RedisClusterNode clusterGetNodeForSlot(int slot)
RedisClusterCommands
RedisClusterNode
serving given slot.clusterGetNodeForSlot
in interface RedisClusterCommands
public RedisClusterNode clusterGetNodeForKey(byte[] key)
RedisClusterCommands
RedisClusterNode
serving given key.clusterGetNodeForKey
in interface RedisClusterCommands
key
- must not be null.public ClusterInfo clusterGetClusterInfo()
RedisClusterCommands
clusterGetClusterInfo
in interface RedisClusterCommands
public void clusterAddSlots(RedisClusterNode node, int... slots)
RedisClusterCommands
RedisClusterNode
.clusterAddSlots
in interface RedisClusterCommands
node
- must not be null.public void clusterAddSlots(RedisClusterNode node, RedisClusterNode.SlotRange range)
RedisClusterCommands
RedisClusterNode.SlotRange.getSlotsArray()
to given RedisClusterNode
.clusterAddSlots
in interface RedisClusterCommands
node
- must not be null.range
- must not be null.public void clusterDeleteSlots(RedisClusterNode node, int... slots)
RedisClusterCommands
RedisClusterNode
.clusterDeleteSlots
in interface RedisClusterCommands
node
- must not be null.public void clusterDeleteSlotsInRange(RedisClusterNode node, RedisClusterNode.SlotRange range)
RedisClusterCommands
RedisClusterNode.SlotRange.getSlotsArray()
from given RedisClusterNode
.clusterDeleteSlotsInRange
in interface RedisClusterCommands
node
- must not be null.range
- must not be null.public void clusterForget(RedisClusterNode node)
RedisClusterCommands
clusterForget
in interface RedisClusterCommands
node
- must not be null.public void clusterMeet(RedisClusterNode node)
RedisClusterCommands
clusterMeet
in interface RedisClusterCommands
node
- must contain host
and RedisNode.getPort()
and must
not be null.public void clusterSetSlot(RedisClusterNode node, int slot, RedisClusterCommands.AddSlots mode)
clusterSetSlot
in interface RedisClusterCommands
node
- must not be null.mode
- must not benull.public List<byte[]> clusterGetKeysInSlot(int slot, Integer count)
RedisClusterCommands
clusterGetKeysInSlot
in interface RedisClusterCommands
count
- must not be null.public Long clusterCountKeysInSlot(int slot)
RedisClusterCommands
clusterCountKeysInSlot
in interface RedisClusterCommands
public void clusterReplicate(RedisClusterNode master, RedisClusterNode slave)
RedisClusterCommands
clusterReplicate
in interface RedisClusterCommands
master
- must not be null.slave
- must not be null.public String ping()
RedisConnectionCommands
ping
in interface RedisConnectionCommands
ping
in class LettuceConnection
public String ping(RedisClusterNode node)
ping
in interface RedisClusterConnection
node
- must not be null.RedisConnectionCommands.ping()
public Set<byte[]> keys(RedisClusterNode node, byte[] pattern)
keys
in interface RedisClusterConnection
node
- must not be null.pattern
- must not be null.RedisKeyCommands.keys(byte[])
public byte[] randomKey(RedisClusterNode node)
randomKey
in interface RedisClusterConnection
node
- must not be null.RedisKeyCommands.randomKey()
public void select(int dbIndex)
RedisConnectionCommands
dbIndex
.select
in interface RedisConnectionCommands
select
in class LettuceConnection
dbIndex
- the database index.protected io.lettuce.core.api.StatefulConnection<byte[],byte[]> doGetAsyncDedicatedConnection()
doGetAsyncDedicatedConnection
in class LettuceConnection
public List<RedisClusterNode> clusterGetNodes()
RedisClusterCommands
clusterGetNodes
in interface RedisClusterCommands
public void watch(byte[]... keys)
RedisTxCommands
keys
for modifications during transaction started with RedisTxCommands.multi()
.watch
in interface RedisTxCommands
watch
in class LettuceConnection
keys
- must not be null.public void unwatch()
RedisTxCommands
#watch(byte[]...)
keys.unwatch
in interface RedisTxCommands
unwatch
in class LettuceConnection
public void multi()
RedisTxCommands
RedisTxCommands.exec()
or rolled back using RedisTxCommands.discard()
multi
in interface RedisTxCommands
multi
in class LettuceConnection
public Map<RedisClusterNode,Collection<RedisClusterNode>> clusterGetMasterSlaveMap()
RedisClusterCommands
clusterGetMasterSlaveMap
in interface RedisClusterCommands
protected io.lettuce.core.pubsub.StatefulRedisPubSubConnection<byte[],byte[]> switchToPubSub()
LettuceConnection
LettuceConnection.close()
the current connection and open a new pub/sub connection to the Redis server.switchToPubSub
in class LettuceConnection
public ClusterCommandExecutor getClusterCommandExecutor()
public void close() throws DataAccessException
RedisConnection
close
in interface RedisConnection
close
in class LettuceConnection
DataAccessException
Copyright © 2011–2017 Pivotal Software, Inc.. All rights reserved.