Module lettuce.core
Interface RedisClusterAsyncCommands<K,V>
- Type Parameters:
K- Key type.V- Value type.
- All Superinterfaces:
BaseRedisAsyncCommands<K,V>,RedisAclAsyncCommands<K,V>,RedisGeoAsyncCommands<K,V>,RedisHashAsyncCommands<K,V>,RedisHLLAsyncCommands<K,V>,RedisKeyAsyncCommands<K,V>,RedisListAsyncCommands<K,V>,RedisScriptingAsyncCommands<K,V>,RedisServerAsyncCommands<K,V>,RedisSetAsyncCommands<K,V>,RedisSortedSetAsyncCommands<K,V>,RedisStreamAsyncCommands<K,V>,RedisStringAsyncCommands<K,V>
- All Known Subinterfaces:
RedisAdvancedClusterAsyncCommands<K,V>,RedisAsyncCommands<K,V>,RedisClusterPubSubAsyncCommands<K,V>,RedisPubSubAsyncCommands<K,V>
- All Known Implementing Classes:
AbstractRedisAsyncCommands,RedisAdvancedClusterAsyncCommandsImpl,RedisAsyncCommandsImpl,RedisClusterPubSubAsyncCommandsImpl,RedisPubSubAsyncCommandsImpl
public interface RedisClusterAsyncCommands<K,V> extends BaseRedisAsyncCommands<K,V>, RedisAclAsyncCommands<K,V>, RedisGeoAsyncCommands<K,V>, RedisHashAsyncCommands<K,V>, RedisHLLAsyncCommands<K,V>, RedisKeyAsyncCommands<K,V>, RedisListAsyncCommands<K,V>, RedisScriptingAsyncCommands<K,V>, RedisServerAsyncCommands<K,V>, RedisSetAsyncCommands<K,V>, RedisSortedSetAsyncCommands<K,V>, RedisStreamAsyncCommands<K,V>, RedisStringAsyncCommands<K,V>
A complete asynchronous and thread-safe cluster Redis API with 400+ Methods.
- Since:
- 4.0
- Author:
- Mark Paluch
-
Method Summary
Modifier and Type Method Description RedisFuture<String>asking()The asking command is required after a-ASKredirection.RedisFuture<String>auth(CharSequence password)Authenticate to the server.RedisFuture<String>auth(String username, CharSequence password)Authenticate to the server with username and password.RedisFuture<String>clusterAddSlots(int... slots)Adds slots to the cluster node.RedisFuture<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.RedisFuture<Long>clusterCountFailureReports(String nodeId)Returns the number of failure reports for the specified node.RedisFuture<Long>clusterCountKeysInSlot(int slot)Returns the number of keys in the specified Redis Cluster hashslot.RedisFuture<String>clusterDelSlots(int... slots)Removes slots from the cluster node.RedisFuture<String>clusterFailover(boolean force)Failover a cluster node.RedisFuture<String>clusterFlushslots()Delete all the slots associated with the specified node.RedisFuture<String>clusterForget(String nodeId)Disallow connections and remove the cluster node from the cluster.RedisFuture<List<K>>clusterGetKeysInSlot(int slot, int count)Retrieve the list of keys within theslot.RedisFuture<String>clusterInfo()Get information and statistics about the cluster viewed by the current node.RedisFuture<Long>clusterKeyslot(K key)Returns an integer identifying the hash slot the specified key hashes to.RedisFuture<String>clusterMeet(String ip, int port)Meet another cluster node to include the node into the cluster.RedisFuture<String>clusterMyId()Obtain the nodeId for the currently connected node.RedisFuture<String>clusterNodes()Obtain details about all cluster nodes.RedisFuture<String>clusterReplicate(String nodeId)Turn this node into a replica of the node with the idnodeId.RedisFuture<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 awayRedisFuture<String>clusterSaveconfig()Forces a node to save the nodes.conf configuration on disk.RedisFuture<String>clusterSetConfigEpoch(long configEpoch)This command sets a specific config epoch in a fresh node.RedisFuture<String>clusterSetSlotImporting(int slot, String nodeId)Flag a slot as IMPORTING (incoming) from the node specified innodeId.RedisFuture<String>clusterSetSlotMigrating(int slot, String nodeId)Flag a slot as MIGRATING (outgoing) towards the node specified innodeId.RedisFuture<String>clusterSetSlotNode(int slot, String nodeId)Assign a slot to a node.RedisFuture<String>clusterSetSlotStable(int slot)Clears migrating / importing state from the slot.RedisFuture<List<String>>clusterSlaves(String nodeId)List replicas for a certain node identified by itsnodeId.RedisFuture<List<Object>>clusterSlots()Get array of cluster slots to node mappings.RedisFuture<Long>del(K... keys)Delete a key with pipelining.RedisFuture<List<KeyValue<K,V>>>mget(K... keys)Get the values of all the given keys with pipelining.RedisFuture<String>mset(Map<K,V> map)Set multiple keys to multiple values with pipelining.RedisFuture<Boolean>msetnx(Map<K,V> map)Set multiple keys to multiple values, only if none of the keys exist with pipelining.RedisFuture<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.RedisFuture<String>readWrite()Resets readOnly flag.voidsetTimeout(Duration timeout)Set the default timeout for operations.Methods inherited from interface io.lettuce.core.api.async.BaseRedisAsyncCommands
dispatch, dispatch, echo, flushCommands, isOpen, ping, publish, pubsubChannels, pubsubChannels, pubsubNumpat, pubsubNumsub, quit, reset, role, setAutoFlushCommands, waitForReplicationMethods inherited from interface io.lettuce.core.api.async.RedisAclAsyncCommands
aclCat, aclCat, aclDeluser, aclGenpass, aclGenpass, aclGetuser, aclList, aclLoad, aclLog, aclLog, aclLogReset, aclSave, aclSetuser, aclUsers, aclWhoamiMethods inherited from interface io.lettuce.core.api.async.RedisGeoAsyncCommands
geoadd, geoadd, geoadd, geoadd, geoadd, geoadd, geodist, geohash, geopos, georadius, georadius, georadius, georadiusbymember, georadiusbymember, georadiusbymember, geosearch, geosearch, geosearchstoreMethods inherited from interface io.lettuce.core.api.async.RedisHashAsyncCommands
hdel, hexists, hget, hgetall, hgetall, hincrby, hincrbyfloat, hkeys, hkeys, hlen, hmget, hmget, hmset, hrandfield, hrandfield, hrandfieldWithvalues, hrandfieldWithvalues, hscan, hscan, hscan, hscan, hscan, hscan, hscan, hscan, hset, hset, hsetnx, hstrlen, hvals, hvalsMethods inherited from interface io.lettuce.core.api.async.RedisHLLAsyncCommands
pfadd, pfcount, pfmergeMethods inherited from interface io.lettuce.core.api.async.RedisKeyAsyncCommands
copy, copy, dump, exists, expire, expire, expireat, expireat, expireat, keys, keys, migrate, migrate, move, objectEncoding, objectFreq, objectIdletime, objectRefcount, persist, pexpire, pexpire, pexpireat, pexpireat, pexpireat, pttl, randomkey, rename, renamenx, restore, restore, scan, scan, scan, scan, scan, scan, scan, scan, sort, sort, sort, sort, sortStore, touch, ttl, type, unlinkMethods inherited from interface io.lettuce.core.api.async.RedisListAsyncCommands
blmove, blpop, brpop, brpoplpush, lindex, linsert, llen, lmove, lpop, lpop, lpos, lpos, lpos, lpos, lpush, lpushx, lrange, lrange, lrem, lset, ltrim, rpop, rpop, rpoplpush, rpush, rpushxMethods inherited from interface io.lettuce.core.api.async.RedisScriptingAsyncCommands
digest, digest, eval, eval, eval, eval, evalsha, evalsha, scriptExists, scriptFlush, scriptFlush, scriptKill, scriptLoad, scriptLoadMethods inherited from interface io.lettuce.core.api.async.RedisServerAsyncCommands
bgrewriteaof, bgsave, clientCaching, clientGetname, clientGetredir, clientId, clientKill, clientKill, clientList, clientPause, clientSetname, clientTracking, clientUnblock, command, commandCount, commandInfo, commandInfo, configGet, configResetstat, configRewrite, configSet, dbsize, debugCrashAndRecover, debugHtstats, debugObject, debugOom, debugReload, debugRestart, debugSdslen, debugSegfault, flushall, flushall, flushallAsync, flushdb, flushdb, flushdbAsync, info, info, lastsave, memoryUsage, save, shutdown, slaveof, slaveofNoOne, slowlogGet, slowlogGet, slowlogLen, slowlogReset, timeMethods inherited from interface io.lettuce.core.api.async.RedisSetAsyncCommands
sadd, scard, sdiff, sdiff, sdiffstore, sinter, sinter, sinterstore, sismember, smembers, smembers, smismember, smove, spop, spop, srandmember, srandmember, srandmember, srem, sscan, sscan, sscan, sscan, sscan, sscan, sscan, sscan, sunion, sunion, sunionstoreMethods inherited from interface io.lettuce.core.api.async.RedisSortedSetAsyncCommands
bzpopmax, bzpopmin, zadd, zadd, zadd, zadd, zadd, zadd, zaddincr, zaddincr, zcard, zcount, zcount, zcount, zdiff, zdiffstore, zdiffWithScores, zincrby, zinter, zinter, zinterstore, zinterstore, zinterWithScores, zinterWithScores, zlexcount, zlexcount, 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, zrangestorebylex, zrangestorebyscore, zrangeWithScores, zrangeWithScores, zrank, 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, zrevrangestorebylex, zrevrangestorebyscore, zrevrangeWithScores, zrevrangeWithScores, zrevrank, zscan, zscan, zscan, zscan, zscan, zscan, zscan, zscan, zscore, zunion, zunion, zunionstore, zunionstore, zunionWithScores, zunionWithScoresMethods inherited from interface io.lettuce.core.api.async.RedisStreamAsyncCommands
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, xtrimMethods inherited from interface io.lettuce.core.api.async.RedisStringAsyncCommands
append, bitcount, bitcount, bitfield, bitopAnd, bitopNot, bitopOr, bitopXor, bitpos, bitpos, bitpos, decr, decrby, get, getbit, getdel, getex, getrange, getset, incr, incrby, incrbyfloat, mget, psetex, set, set, setbit, setex, setGet, setGet, setnx, setrange, stralgoLcs, strlen
-
Method Details
-
setTimeout
Set the default timeout for operations. A zero timeout value indicates to not time out.- Parameters:
timeout- the timeout value- Since:
- 5.0
-
auth
Authenticate to the server.- Parameters:
password- the password- Returns:
- String simple-string-reply
-
auth
Authenticate to the server with username and password. Requires Redis 6 or newer.- Parameters:
username- the usernamepassword- the password- Returns:
- String simple-string-reply
- Since:
- 6.0
-
clusterBumpepoch
RedisFuture<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.- Returns:
- String simple-string-reply If the new config epoch is generated and assigned either BUMPED (epoch) or STILL (epoch) are returned.
-
clusterMeet
Meet another cluster node to include the node into the cluster. The command starts the cluster handshake and returns with OK when the node was added to the cluster.- Parameters:
ip- IP address of the hostport- port number.- Returns:
- String simple-string-reply
-
clusterForget
Disallow connections and remove the cluster node from the cluster.- Parameters:
nodeId- the node Id- Returns:
- String simple-string-reply
-
clusterAddSlots
Adds slots to the cluster node. The current node will become the upstream for the specified slots.- Parameters:
slots- one or more slots from 0 to 16384- Returns:
- String simple-string-reply
-
clusterDelSlots
Removes slots from the cluster node.- Parameters:
slots- one or more slots from 0 to 16384- Returns:
- String simple-string-reply
-
clusterSetSlotNode
Assign a slot to a node. The command migrates the specified slot from the current node to the specified node innodeId- Parameters:
slot- the slotnodeId- the id of the node that will become the master for the slot- Returns:
- String simple-string-reply
-
clusterSetSlotStable
Clears migrating / importing state from the slot.- Parameters:
slot- the slot- Returns:
- String simple-string-reply
-
clusterSetSlotMigrating
Flag a slot as MIGRATING (outgoing) towards the node specified innodeId. The slot must be handled by the current node in order to be migrated.- Parameters:
slot- the slotnodeId- the id of the node is targeted to become the master for the slot- Returns:
- String simple-string-reply
-
clusterSetSlotImporting
Flag a slot as IMPORTING (incoming) from the node specified innodeId.- Parameters:
slot- the slotnodeId- the id of the node is the master of the slot- Returns:
- String simple-string-reply
-
clusterInfo
RedisFuture<String> clusterInfo()Get information and statistics about the cluster viewed by the current node.- Returns:
- String bulk-string-reply as a collection of text lines.
-
clusterMyId
RedisFuture<String> clusterMyId()Obtain the nodeId for the currently connected node.- Returns:
- String simple-string-reply
-
clusterNodes
RedisFuture<String> clusterNodes()Obtain details about all cluster nodes. Can be parsed usingClusterPartitionParser.parse(java.lang.String)- Returns:
- String bulk-string-reply as a collection of text lines
-
clusterSlaves
List replicas for a certain node identified by itsnodeId. Can be parsed usingClusterPartitionParser.parse(java.lang.String)- Parameters:
nodeId- node id of the master node- Returns:
- List<String> array-reply list of replicas. The command returns data in the same format as
clusterNodes()but one line per replica.
-
clusterGetKeysInSlot
Retrieve the list of keys within theslot.- Parameters:
slot- the slotcount- maximal number of keys- Returns:
- List<K> array-reply list of keys
-
clusterCountKeysInSlot
Returns the number of keys in the specified Redis Cluster hashslot.- Parameters:
slot- the slot- Returns:
- Integer reply: The number of keys in the specified hash slot, or an error if the hash slot is invalid.
-
clusterCountFailureReports
Returns the number of failure reports for the specified node. Failure reports are the way Redis Cluster uses in order to promote a PFAIL state, that means a node is not reachable, to a FAIL state, that means that the majority of masters in the cluster agreed within a window of time that the node is not reachable.- Parameters:
nodeId- the node id- Returns:
- Integer reply: The number of active failure reports for the node.
-
clusterKeyslot
Returns an integer identifying the hash slot the specified key hashes to. This command is mainly useful for debugging and testing, since it exposes via an API the underlying Redis implementation of the hashing algorithm. Basically the same asSlotHash.getSlot(byte[]). If not, call Houston and report that we've got a problem.- Parameters:
key- the key.- Returns:
- Integer reply: The hash slot number.
-
clusterSaveconfig
RedisFuture<String> clusterSaveconfig()Forces a node to save the nodes.conf configuration on disk.- Returns:
- String simple-string-reply:
OKor an error if the operation fails.
-
clusterSetConfigEpoch
This command sets a specific config epoch in a fresh node. It only works when:- The nodes table of the node is empty.
- The node current config epoch is zero.
- Parameters:
configEpoch- the config epoch- Returns:
- String simple-string-reply:
OKor an error if the operation fails.
-
clusterSlots
RedisFuture<List<Object>> clusterSlots()Get array of cluster slots to node mappings.- Returns:
- RedisFuture<List<Object>> array-reply nested list of slot ranges with IP/Port mappings.
-
asking
RedisFuture<String> asking()The asking command is required after a-ASKredirection. The client should issueASKINGbefore to actually send the command to the target instance. See the Redis Cluster specification for more information.- Returns:
- String simple-string-reply
-
clusterReplicate
Turn this node into a replica of the node with the idnodeId.- Parameters:
nodeId- master node id- Returns:
- String simple-string-reply
-
clusterFailover
Failover a cluster node. Turns the currently connected node into a master and the master into its replica.- Parameters:
force- do not coordinate with master iftrue- Returns:
- String simple-string-reply
-
clusterReset
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
- Parameters:
hard-truefor hard reset. Generates a new nodeId and currentEpoch/configEpoch are set to 0- Returns:
- String simple-string-reply
-
clusterFlushslots
RedisFuture<String> clusterFlushslots()Delete all the slots associated with the specified node. The number of deleted slots is returned.- Returns:
- String simple-string-reply
-
readOnly
RedisFuture<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.- Specified by:
readOnlyin interfaceBaseRedisAsyncCommands<K,V>- Returns:
- String simple-string-reply
-
readWrite
RedisFuture<String> readWrite()Resets readOnly flag.- Specified by:
readWritein interfaceBaseRedisAsyncCommands<K,V>- Returns:
- String simple-string-reply
-
del
Delete a key with pipelining. Cross-slot keys will result in multiple calls to the particular cluster nodes.- Specified by:
delin interfaceRedisKeyAsyncCommands<K,V>- Parameters:
keys- the key- Returns:
- RedisFuture<Long> integer-reply The number of keys that were removed.
-
mget
Get the values of all the given keys with pipelining. Cross-slot keys will result in multiple calls to the particular cluster nodes.- Specified by:
mgetin interfaceRedisStringAsyncCommands<K,V>- Parameters:
keys- the key- Returns:
- RedisFuture<List<V>> array-reply list of values at the specified keys.
-
mset
Set multiple keys to multiple values with pipelining. Cross-slot keys will result in multiple calls to the particular cluster nodes.- Specified by:
msetin interfaceRedisStringAsyncCommands<K,V>- Parameters:
map- the null- Returns:
- RedisFuture<String> simple-string-reply always
OKsinceMSETcan't fail.
-
msetnx
Set multiple keys to multiple values, only if none of the keys exist with pipelining. Cross-slot keys will result in multiple calls to the particular cluster nodes.- Specified by:
msetnxin interfaceRedisStringAsyncCommands<K,V>- Parameters:
map- the null- Returns:
- RedisFuture<Boolean> integer-reply specifically:
1if the all the keys were set.0if no key was set (at least one key already existed).
-