K
- Key type.V
- Value type.public interface RedisClusterCommands<K,V> extends BaseRedisCommands<K,V>, RedisAclCommands<K,V>, RedisFunctionCommands<K,V>, RedisGeoCommands<K,V>, RedisHashCommands<K,V>, RedisHLLCommands<K,V>, RedisKeyCommands<K,V>, RedisListCommands<K,V>, RedisScriptingCommands<K,V>, RedisServerCommands<K,V>, RedisSetCommands<K,V>, RedisSortedSetCommands<K,V>, RedisStreamCommands<K,V>, RedisStringCommands<K,V>, RedisJsonCommands<K,V>
Modifier and Type | Method and Description |
---|---|
String |
asking()
The asking command is required after a
-ASK redirection. |
String |
auth(CharSequence password)
Authenticate to the server.
|
String |
auth(String username,
CharSequence password)
Authenticate to the server with username and password.
|
String |
clusterAddSlots(int... slots)
Adds slots to the cluster node.
|
String |
clusterAddSlotsRange(Range<Integer>... ranges)
Takes a list of slot ranges (specified by start and end slots) to assign to the node.
|
String |
clusterBumpepoch()
Generate a new config epoch, incrementing the current epoch, assign the new epoch to this node, WITHOUT any consensus and
persist the configuration on disk before sending packets with the new configuration.
|
Long |
clusterCountFailureReports(String nodeId)
Returns the number of failure reports for the specified node.
|
Long |
clusterCountKeysInSlot(int slot)
Returns the number of keys in the specified Redis Cluster hash
slot . |
String |
clusterDelSlots(int... slots)
Removes slots from the cluster node.
|
String |
clusterDelSlotsRange(Range<Integer>... ranges)
Takes a list of slot ranges (specified by start and end slots) to remove to the node.
|
String |
clusterFailover(boolean force)
Failover a cluster node.
|
String |
clusterFailover(boolean force,
boolean takeOver)
Failover a cluster node.
|
String |
clusterFlushslots()
Delete all the slots associated with the specified node.
|
String |
clusterForget(String nodeId)
Disallow connections and remove the cluster node from the cluster.
|
List<K> |
clusterGetKeysInSlot(int slot,
int count)
Retrieve the list of keys within the
slot . |
String |
clusterInfo()
Get information and statistics about the cluster viewed by the current node.
|
Long |
clusterKeyslot(K key)
Returns an integer identifying the hash slot the specified key hashes to.
|
List<Map<String,Object>> |
clusterLinks()
Retrieves information about the TCP links between nodes in a Redis Cluster.
|
String |
clusterMeet(String ip,
int port)
Meet another cluster node to include the node into the cluster.
|
String |
clusterMyId()
Obtain the nodeId for the currently connected node.
|
String |
clusterMyShardId()
Obtain the shard ID for the currently connected node.
|
String |
clusterNodes()
Obtain details about all cluster nodes.
|
List<String> |
clusterReplicas(String nodeId)
List replicas for a certain node identified by its
nodeId . |
String |
clusterReplicate(String nodeId)
Turn this node into a replica of the node with the id
nodeId . |
String |
clusterReset(boolean hard)
Reset a node performing a soft or hard reset:
All other nodes are forgotten
All the assigned / open slots are released
If the node is a replica, it turns into a master
Only for hard reset: a new Node ID is generated
Only for hard reset: currentEpoch and configEpoch are set to 0
The new configuration is saved and the cluster state updated
If the node was a replica, the whole data set is flushed away
|
String |
clusterSaveconfig()
Forces a node to save the nodes.conf configuration on disk.
|
String |
clusterSetConfigEpoch(long configEpoch)
This command sets a specific config epoch in a fresh node.
|
String |
clusterSetSlotImporting(int slot,
String nodeId)
Flag a slot as IMPORTING (incoming) from the node specified in
nodeId . |
String |
clusterSetSlotMigrating(int slot,
String nodeId)
Flag a slot as MIGRATING (outgoing) towards the node specified in
nodeId . |
String |
clusterSetSlotNode(int slot,
String nodeId)
Assign a slot to a node.
|
String |
clusterSetSlotStable(int slot)
Clears migrating / importing state from the slot.
|
List<Object> |
clusterShards()
Get array of cluster shards
|
List<String> |
clusterSlaves(String nodeId)
Deprecated.
since 6.1.7, use
clusterReplicas(String) instead. |
List<Object> |
clusterSlots()
Get array of cluster slots to node mappings.
|
JsonParser |
getJsonParser() |
String |
readOnly()
Tells a Redis cluster replica node that the client is ok reading possibly stale data and is not interested in running
write queries.
|
String |
readWrite()
Resets readOnly flag.
|
void |
setTimeout(Duration timeout)
Deprecated.
since 6.2. Use the corresponding
StatefulConnection.setTimeout(Duration) method
on the connection interface. To be removed with Lettuce 7.0. |
dispatch, dispatch, echo, isOpen, ping, publish, pubsubChannels, pubsubChannels, pubsubNumpat, pubsubNumsub, pubsubShardChannels, pubsubShardChannels, pubsubShardNumsub, quit, reset, role, spublish, waitForReplication
aclCat, aclCat, aclDeluser, aclDryRun, aclDryRun, aclGenpass, aclGenpass, aclGetuser, aclList, aclLoad, aclLog, aclLog, aclLogReset, aclSave, aclSetuser, aclUsers, aclWhoami
fcall, fcall, fcallReadOnly, fcallReadOnly, functionDump, functionFlush, functionKill, functionList, functionList, functionLoad, functionLoad, functionRestore, functionRestore
geoadd, geoadd, geoadd, geoadd, geoadd, geoadd, geodist, geohash, geopos, georadius, georadius, georadius, georadiusbymember, georadiusbymember, georadiusbymember, geosearch, geosearch, geosearchstore
hdel, hexists, hexpire, hexpire, hexpire, hexpire, hexpireat, hexpireat, hexpireat, hexpireat, hexpireat, hexpireat, hexpiretime, hget, hgetall, hgetall, hincrby, hincrbyfloat, hkeys, hkeys, hlen, hmget, hmget, hmset, hpersist, hpexpire, hpexpire, hpexpire, hpexpire, hpexpireat, hpexpireat, hpexpireat, hpexpireat, hpexpireat, hpexpireat, hpexpiretime, hpttl, hrandfield, hrandfield, hrandfieldWithvalues, hrandfieldWithvalues, hscan, hscan, hscan, hscan, hscan, hscan, hscan, hscan, hscanNovalues, hscanNovalues, hscanNovalues, hscanNovalues, hscanNovalues, hscanNovalues, hscanNovalues, hscanNovalues, hset, hset, hsetnx, hstrlen, httl, hvals, hvals
pfadd, pfcount, pfmerge
copy, copy, del, dump, exists, expire, expire, expire, expire, expireat, expireat, expireat, expireat, expireat, expireat, expiretime, keys, keys, migrate, migrate, move, objectEncoding, objectFreq, objectIdletime, objectRefcount, persist, pexpire, pexpire, pexpire, pexpire, pexpireat, pexpireat, pexpireat, pexpireat, pexpireat, pexpireat, pexpiretime, pttl, randomkey, rename, renamenx, restore, restore, scan, scan, scan, scan, scan, scan, scan, scan, sort, sort, sort, sort, sortReadOnly, sortReadOnly, sortReadOnly, sortReadOnly, sortStore, touch, ttl, type, unlink
blmove, blmove, blmpop, blmpop, blpop, blpop, brpop, brpop, brpoplpush, brpoplpush, lindex, linsert, llen, lmove, lmpop, lpop, lpop, lpos, lpos, lpos, lpos, lpush, lpushx, lrange, lrange, lrem, lset, ltrim, rpop, rpop, rpoplpush, rpush, rpushx
digest, digest, eval, eval, eval, eval, evalReadOnly, evalReadOnly, evalsha, evalsha, evalshaReadOnly, scriptExists, scriptFlush, scriptFlush, scriptKill, scriptLoad, scriptLoad
bgrewriteaof, bgsave, clientCaching, clientGetname, clientGetredir, clientId, clientInfo, clientKill, clientKill, clientList, clientList, clientNoEvict, clientPause, clientSetinfo, clientSetname, clientTracking, clientTrackinginfo, clientUnblock, command, commandCount, commandInfo, commandInfo, configGet, configGet, configResetstat, configRewrite, configSet, configSet, dbsize, debugCrashAndRecover, debugHtstats, debugObject, debugOom, debugReload, debugRestart, debugSdslen, debugSegfault, flushall, flushall, flushallAsync, flushdb, flushdb, flushdbAsync, info, info, lastsave, memoryUsage, replicaof, replicaofNoOne, save, shutdown, shutdown, slaveof, slaveofNoOne, slowlogGet, slowlogGet, slowlogLen, slowlogReset, time
sadd, scard, sdiff, sdiff, sdiffstore, sinter, sinter, sintercard, sintercard, sinterstore, sismember, smembers, smembers, smismember, smove, spop, spop, srandmember, srandmember, srandmember, srem, sscan, sscan, sscan, sscan, sscan, sscan, sscan, sscan, sunion, sunion, sunionstore
bzmpop, bzmpop, bzmpop, bzmpop, bzpopmax, bzpopmax, bzpopmin, bzpopmin, zadd, zadd, zadd, zadd, zadd, zadd, zaddincr, zaddincr, zcard, zcount, zcount, zcount, zdiff, zdiffstore, zdiffWithScores, zincrby, zinter, zinter, zintercard, zintercard, zinterstore, zinterstore, zinterWithScores, zinterWithScores, zlexcount, zlexcount, zmpop, zmpop, zmscore, zpopmax, zpopmax, zpopmin, zpopmin, zrandmember, zrandmember, zrandmemberWithScores, zrandmemberWithScores, zrange, zrange, zrangebylex, zrangebylex, zrangebylex, zrangebylex, zrangebyscore, zrangebyscore, zrangebyscore, zrangebyscore, zrangebyscore, zrangebyscore, zrangebyscore, zrangebyscore, zrangebyscore, zrangebyscore, zrangebyscore, zrangebyscore, zrangebyscoreWithScores, zrangebyscoreWithScores, zrangebyscoreWithScores, zrangebyscoreWithScores, zrangebyscoreWithScores, zrangebyscoreWithScores, zrangebyscoreWithScores, zrangebyscoreWithScores, zrangebyscoreWithScores, zrangebyscoreWithScores, zrangebyscoreWithScores, zrangebyscoreWithScores, zrangestore, zrangestorebylex, zrangestorebyscore, zrangeWithScores, zrangeWithScores, zrank, zrankWithScore, zrem, zremrangebylex, zremrangebylex, zremrangebyrank, zremrangebyscore, zremrangebyscore, zremrangebyscore, zrevrange, zrevrange, zrevrangebylex, zrevrangebylex, zrevrangebyscore, zrevrangebyscore, zrevrangebyscore, zrevrangebyscore, zrevrangebyscore, zrevrangebyscore, zrevrangebyscore, zrevrangebyscore, zrevrangebyscore, zrevrangebyscore, zrevrangebyscore, zrevrangebyscore, zrevrangebyscoreWithScores, zrevrangebyscoreWithScores, zrevrangebyscoreWithScores, zrevrangebyscoreWithScores, zrevrangebyscoreWithScores, zrevrangebyscoreWithScores, zrevrangebyscoreWithScores, zrevrangebyscoreWithScores, zrevrangebyscoreWithScores, zrevrangebyscoreWithScores, zrevrangebyscoreWithScores, zrevrangebyscoreWithScores, zrevrangestore, zrevrangestorebylex, zrevrangestorebyscore, zrevrangeWithScores, zrevrangeWithScores, zrevrank, zrevrankWithScore, zscan, zscan, zscan, zscan, zscan, zscan, zscan, zscan, zscore, zunion, zunion, zunionstore, zunionstore, zunionWithScores, zunionWithScores
xack, xadd, xadd, xadd, xadd, xautoclaim, xclaim, xclaim, xdel, xgroupCreate, xgroupCreate, xgroupCreateconsumer, xgroupDelconsumer, xgroupDestroy, xgroupSetid, xinfoConsumers, xinfoGroups, xinfoStream, xlen, xpending, xpending, xpending, xpending, xrange, xrange, xread, xread, xreadgroup, xreadgroup, xrevrange, xrevrange, xtrim, xtrim, xtrim
append, bitcount, bitcount, bitfield, bitopAnd, bitopNot, bitopOr, bitopXor, bitpos, bitpos, bitpos, decr, decrby, get, getbit, getdel, getex, getrange, getset, incr, incrby, incrbyfloat, mget, mget, mset, msetnx, psetex, set, set, setbit, setex, setGet, setGet, setnx, setrange, stralgoLcs, strlen
jsonArrappend, jsonArrappend, jsonArrindex, jsonArrindex, jsonArrinsert, jsonArrlen, jsonArrlen, jsonArrpop, jsonArrpop, jsonArrpop, jsonArrtrim, jsonClear, jsonClear, jsonDel, jsonDel, jsonGet, jsonGet, jsonMerge, jsonMGet, jsonMSet, jsonNumincrby, jsonObjkeys, jsonObjkeys, jsonObjlen, jsonObjlen, jsonSet, jsonSet, jsonStrappend, jsonStrappend, jsonStrlen, jsonStrlen, jsonToggle, jsonType, jsonType
@Deprecated void setTimeout(Duration timeout)
StatefulConnection.setTimeout(Duration)
method
on the connection interface. To be removed with Lettuce 7.0.timeout
- the timeout valueString asking()
-ASK
redirection. The client should issue ASKING
before to
actually send the command to the target instance. See the Redis Cluster specification for more information.String auth(CharSequence password)
password
- the passwordString auth(String username, CharSequence password)
username
- the usernamepassword
- the passwordString clusterAddSlots(int... slots)
slots
- one or more slots from 0 to 16384String clusterBumpepoch()
Long clusterCountFailureReports(String nodeId)
nodeId
- the node idLong clusterCountKeysInSlot(int slot)
slot
.slot
- the slotString clusterAddSlotsRange(Range<Integer>... ranges)
ranges
- a list of slot ranges (specified by start and end slots)String clusterDelSlots(int... slots)
slots
- one or more slots from 0 to 16384String clusterDelSlotsRange(Range<Integer>... ranges)
ranges
- a list of slot ranges (specified by start and end slots)String clusterFailover(boolean force)
force
- do not coordinate with master if true
String clusterFailover(boolean force, boolean takeOver)
force
- do not coordinate with master if true
takeOver
- do not coordinate with the rest of the cluster if true
force will take precedence over takeOver
if both are set.String clusterFlushslots()
String clusterForget(String nodeId)
nodeId
- the node IdList<K> clusterGetKeysInSlot(int slot, int count)
slot
.slot
- the slotcount
- maximal number of keysString clusterInfo()
Long clusterKeyslot(K key)
SlotHash.getSlot(byte[])
. If not, call Houston and report that we've got a problem.key
- the key.String clusterMeet(String ip, int port)
ip
- IP address of the hostport
- port number.String clusterMyId()
String clusterMyShardId()
The CLUSTER MYSHARDID command returns the unique, auto-generated identifier that is associated with the shard to which the connected cluster node belongs.
String clusterNodes()
ClusterPartitionParser.parse(java.util.List<java.lang.Object>)
String clusterReplicate(String nodeId)
nodeId
.nodeId
- master node idList<String> clusterReplicas(String nodeId)
nodeId
. Can be parsed using
ClusterPartitionParser.parse(java.util.List<java.lang.Object>)
nodeId
- node id of the master nodeclusterNodes()
but one line per replica.String clusterReset(boolean hard)
hard
- true
for hard reset. Generates a new nodeId and currentEpoch/configEpoch are set to 0String clusterSaveconfig()
OK
or an error if the operation fails.String clusterSetConfigEpoch(long configEpoch)
configEpoch
- the config epochOK
or an error if the operation fails.String clusterSetSlotImporting(int slot, String nodeId)
nodeId
.slot
- the slotnodeId
- the id of the node is the master of the slotString clusterSetSlotMigrating(int slot, String nodeId)
nodeId
. The slot must be handled by
the current node in order to be migrated.slot
- the slotnodeId
- the id of the node is targeted to become the master for the slotString clusterSetSlotNode(int slot, String nodeId)
nodeId
slot
- the slotnodeId
- the id of the node that will become the master for the slotString clusterSetSlotStable(int slot)
slot
- the slotList<Object> clusterShards()
@Deprecated List<String> clusterSlaves(String nodeId)
clusterReplicas(String)
instead.nodeId
. Can be parsed using
ClusterPartitionParser.parse(java.util.List<java.lang.Object>)
nodeId
- node id of the master nodeclusterNodes()
but one line per replica.List<Object> clusterSlots()
String readOnly()
readOnly
in interface BaseRedisCommands<K,V>
String readWrite()
readWrite
in interface BaseRedisCommands<K,V>
List<Map<String,Object>> clusterLinks()
JsonParser getJsonParser()
JsonParser
Copyright © 2025 lettuce.io. All rights reserved.