Module lettuce.core
Package io.lettuce.core.cluster.api.sync
Interface RedisAdvancedClusterCommands<K,V>
- All Superinterfaces:
BaseRedisCommands<K,V>,RedisAclCommands<K,V>,RedisClusterCommands<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>
public interface RedisAdvancedClusterCommands<K,V> extends RedisClusterCommands<K,V>
Advanced synchronous and thread-safe Redis Cluster API.
- Since:
- 4.0
- Author:
- Mark Paluch, Jon Chambers
-
Method Summary
Modifier and Type Method Description default NodeSelection<K,V>all()Select all known cluster nodes.StringclientSetname(K name)Set the current connection name on all known cluster nodes with pipelining.Longdbsize()Return the number of keys in the selected database on all cluster upstream nodes.Longdel(K... keys)Delete one or more keys with pipelining.Longexists(K... keys)Determine how many keys exist with pipelining.Stringflushall()Remove all keys from all databases on all cluster upstream nodes with pipelining.StringflushallAsync()Remove all keys asynchronously from all databases on all cluster upstream nodes with pipelining.Stringflushdb()Remove all keys from the current database on all cluster upstream nodes with pipelining.RedisClusterCommands<K,V>getConnection(String nodeId)Retrieve a connection to the specified cluster node using the nodeId.RedisClusterCommands<K,V>getConnection(String host, int port)Retrieve a connection to the specified cluster node using host and port.StatefulRedisClusterConnection<K,V>getStatefulConnection()Longkeys(KeyStreamingChannel<K> channel, K pattern)Find all keys matching the given pattern on all cluster upstream nodes.List<K>keys(K pattern)Find all keys matching the given pattern on all cluster upstream nodes.default NodeSelection<K,V>masters()Deprecated.List<KeyValue<K,V>>mget(K... keys)Get the values of all the given keys with pipelining.Stringmset(Map<K,V> map)Set multiple keys to multiple values with pipelining.Booleanmsetnx(Map<K,V> map)Set multiple keys to multiple values, only if none of the keys exist with pipelining.NodeSelection<K,V>nodes(Predicate<RedisClusterNode> predicate)Select nodes by a predicate and keeps a static selection.NodeSelection<K,V>nodes(Predicate<RedisClusterNode> predicate, boolean dynamic)Select nodes by a predicateKrandomkey()Return a random key from the keyspace on a random master.NodeSelection<K,V>readonly(Predicate<RedisClusterNode> predicate)Select replica nodes by a predicate and keeps a static selection.default NodeSelection<K,V>replicas()Select all replicas.default NodeSelection<K,V>replicas(Predicate<RedisClusterNode> predicate)Select all replicas.KeyScanCursor<K>scan()Incrementally iterate the keys space over the whole Cluster.StreamScanCursorscan(KeyStreamingChannel<K> channel)Incrementally iterate the keys space over the whole Cluster.StreamScanCursorscan(KeyStreamingChannel<K> channel, ScanArgs scanArgs)Incrementally iterate the keys space over the whole Cluster.StreamScanCursorscan(KeyStreamingChannel<K> channel, ScanCursor scanCursor)Incrementally iterate the keys space over the whole Cluster.StreamScanCursorscan(KeyStreamingChannel<K> channel, ScanCursor scanCursor, ScanArgs scanArgs)Incrementally iterate the keys space over the whole Cluster.KeyScanCursor<K>scan(ScanArgs scanArgs)Incrementally iterate the keys space over the whole Cluster.KeyScanCursor<K>scan(ScanCursor scanCursor)Incrementally iterate the keys space over the whole Cluster.KeyScanCursor<K>scan(ScanCursor scanCursor, ScanArgs scanArgs)Incrementally iterate the keys space over the whole Cluster.StringscriptFlush()Remove all the scripts from the script cache on all cluster nodes.StringscriptKill()Kill the script currently in execution on all cluster nodes.voidshutdown(boolean save)Synchronously save the dataset to disk and then shut down all nodes of the cluster.default NodeSelection<K,V>slaves()Deprecated.since 5.2, usereplicas()default NodeSelection<K,V>slaves(Predicate<RedisClusterNode> predicate)Deprecated.since 5.2, usereplicas(Predicate)Longtouch(K... keys)Touch one or more keys with pipelining.Longunlink(K... keys)Unlink one or more keys with pipelining.default NodeSelection<K,V>upstream()Select all upstream nodes.Methods inherited from interface io.lettuce.core.api.sync.BaseRedisCommands
dispatch, dispatch, echo, isOpen, ping, publish, pubsubChannels, pubsubChannels, pubsubNumpat, pubsubNumsub, quit, reset, role, waitForReplicationMethods inherited from interface io.lettuce.core.api.sync.RedisAclCommands
aclCat, aclCat, aclDeluser, aclGenpass, aclGenpass, aclGetuser, aclList, aclLoad, aclLog, aclLog, aclLogReset, aclSave, aclSetuser, aclUsers, aclWhoamiMethods inherited from interface io.lettuce.core.cluster.api.sync.RedisClusterCommands
asking, auth, auth, clusterAddSlots, clusterBumpepoch, clusterCountFailureReports, clusterCountKeysInSlot, clusterDelSlots, clusterFailover, clusterFlushslots, clusterForget, clusterGetKeysInSlot, clusterInfo, clusterKeyslot, clusterMeet, clusterMyId, clusterNodes, clusterReplicate, clusterReset, clusterSaveconfig, clusterSetConfigEpoch, clusterSetSlotImporting, clusterSetSlotMigrating, clusterSetSlotNode, clusterSetSlotStable, clusterSlaves, clusterSlots, readOnly, readWrite, setTimeoutMethods inherited from interface io.lettuce.core.api.sync.RedisGeoCommands
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.sync.RedisHashCommands
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.sync.RedisHLLCommands
pfadd, pfcount, pfmergeMethods inherited from interface io.lettuce.core.api.sync.RedisKeyCommands
copy, copy, dump, expire, expire, expireat, expireat, expireat, migrate, migrate, move, objectEncoding, objectFreq, objectIdletime, objectRefcount, persist, pexpire, pexpire, pexpireat, pexpireat, pexpireat, pttl, rename, renamenx, restore, restore, sort, sort, sort, sort, sortStore, ttl, typeMethods inherited from interface io.lettuce.core.api.sync.RedisListCommands
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.sync.RedisScriptingCommands
digest, digest, eval, eval, eval, eval, evalsha, evalsha, scriptExists, scriptFlush, scriptLoad, scriptLoadMethods inherited from interface io.lettuce.core.api.sync.RedisServerCommands
bgrewriteaof, bgsave, clientCaching, clientGetname, clientGetredir, clientId, clientKill, clientKill, clientList, clientPause, clientTracking, clientUnblock, command, commandCount, commandInfo, commandInfo, configGet, configResetstat, configRewrite, configSet, debugCrashAndRecover, debugHtstats, debugObject, debugOom, debugReload, debugRestart, debugSdslen, debugSegfault, flushall, flushdb, flushdbAsync, info, info, lastsave, memoryUsage, save, slaveof, slaveofNoOne, slowlogGet, slowlogGet, slowlogLen, slowlogReset, timeMethods inherited from interface io.lettuce.core.api.sync.RedisSetCommands
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.sync.RedisSortedSetCommands
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.sync.RedisStreamCommands
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.sync.RedisStringCommands
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
-
getConnection
Retrieve a connection to the specified cluster node using the nodeId. Host and port are looked up in the node list. In contrast to theRedisAdvancedClusterCommands, node-connections do not route commands to other cluster nodes- Parameters:
nodeId- the node Id- Returns:
- a connection to the requested cluster node
-
getConnection
Retrieve a connection to the specified cluster node using host and port. In contrast to theRedisAdvancedClusterCommands, node-connections do not route commands to other cluster nodes. Host and port connections are verified by default for cluster membership, seeClusterClientOptions.isValidateClusterNodeMembership().- Parameters:
host- the hostport- the port- Returns:
- a connection to the requested cluster node
-
getStatefulConnection
StatefulRedisClusterConnection<K,V> getStatefulConnection()- Returns:
- the underlying connection.
-
masters
Deprecated.since 6.0 in favor ofupstream().Select all upstream nodes.- Returns:
- API with synchronous executed commands on a selection of upstream cluster nodes.
-
upstream
Select all upstream nodes.- Returns:
- API with synchronous executed commands on a selection of upstream cluster nodes.
-
slaves
Deprecated.since 5.2, usereplicas()Select all replicas.- Returns:
- API with synchronous executed commands on a selection of replica cluster nodes.
-
slaves
Deprecated.since 5.2, usereplicas(Predicate)Select all replicas.- Parameters:
predicate- Predicate to filter nodes- Returns:
- API with synchronous executed commands on a selection of replica cluster nodes.
-
replicas
Select all replicas.- Returns:
- API with synchronous executed commands on a selection of replica cluster nodes.
- Since:
- 5.2
-
replicas
Select all replicas.- Parameters:
predicate- Predicate to filter nodes- Returns:
- API with synchronous executed commands on a selection of replica cluster nodes.
- Since:
- 5.2
-
all
Select all known cluster nodes.- Returns:
- API with synchronous executed commands on a selection of all cluster nodes.
-
readonly
Select replica nodes by a predicate and keeps a static selection. Replica connections operate in READONLY mode. The set of nodes within theNodeSelectionSupportdoes not change when the cluster view changes.- Parameters:
predicate- Predicate to filter nodes- Returns:
- API with synchronous executed commands on a selection of cluster nodes matching
predicate
-
nodes
Select nodes by a predicate and keeps a static selection. The set of nodes within theNodeSelectionSupportdoes not change when the cluster view changes.- Parameters:
predicate- Predicate to filter nodes- Returns:
- API with synchronous executed commands on a selection of cluster nodes matching
predicate
-
nodes
Select nodes by a predicate- Parameters:
predicate- Predicate to filter nodesdynamic- Defines, whether the set of nodes within theNodeSelectionSupportcan change when the cluster view changes.- Returns:
- API with synchronous executed commands on a selection of cluster nodes matching
predicate
-
del
Delete one or more keys with pipelining. Cross-slot keys will result in multiple calls to the particular cluster nodes.- Specified by:
delin interfaceRedisKeyCommands<K,V>- Parameters:
keys- the keys- Returns:
- Long integer-reply The number of keys that were removed.
- See Also:
RedisKeyCommands.del(Object[])
-
unlink
Unlink one or more keys with pipelining. Cross-slot keys will result in multiple calls to the particular cluster nodes.- Specified by:
unlinkin interfaceRedisKeyCommands<K,V>- Parameters:
keys- the keys- Returns:
- Long integer-reply The number of keys that were removed.
- See Also:
RedisKeyCommands.unlink(Object[])
-
exists
Determine how many keys exist with pipelining. Cross-slot keys will result in multiple calls to the particular cluster nodes.- Specified by:
existsin interfaceRedisKeyCommands<K,V>- Parameters:
keys- the keys- Returns:
- Long integer-reply specifically: Number of existing keys
-
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 interfaceRedisStringCommands<K,V>- Parameters:
keys- the key- Returns:
- List<V> array-reply list of values at the specified keys.
- See Also:
RedisStringCommands.mget(Object[])
-
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 interfaceRedisStringCommands<K,V>- Parameters:
map- the map- Returns:
- String simple-string-reply always
OKsinceMSETcan't fail. - See Also:
RedisStringCommands.mset(Map)
-
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 interfaceRedisStringCommands<K,V>- Parameters:
map- the null- Returns:
- Boolean integer-reply specifically:
1if the all the keys were set.0if no key was set (at least one key already existed). - See Also:
RedisStringCommands.msetnx(Map)
-
clientSetname
Set the current connection name on all known cluster nodes with pipelining.- Specified by:
clientSetnamein interfaceRedisServerCommands<K,V>- Parameters:
name- the client name- Returns:
- simple-string-reply
OKif the connection name was successfully set. - See Also:
RedisServerCommands.clientSetname(Object)
-
flushall
String flushall()Remove all keys from all databases on all cluster upstream nodes with pipelining.- Specified by:
flushallin interfaceRedisServerCommands<K,V>- Returns:
- String simple-string-reply
- See Also:
RedisServerCommands.flushall()
-
flushallAsync
String flushallAsync()Remove all keys asynchronously from all databases on all cluster upstream nodes with pipelining.- Specified by:
flushallAsyncin interfaceRedisServerCommands<K,V>- Returns:
- String simple-string-reply
- Since:
- 6.0
- See Also:
RedisServerCommands.flushallAsync()
-
flushdb
String flushdb()Remove all keys from the current database on all cluster upstream nodes with pipelining.- Specified by:
flushdbin interfaceRedisServerCommands<K,V>- Returns:
- String simple-string-reply
- See Also:
RedisServerCommands.flushdb()
-
dbsize
Long dbsize()Return the number of keys in the selected database on all cluster upstream nodes.- Specified by:
dbsizein interfaceRedisServerCommands<K,V>- Returns:
- Long integer-reply
- See Also:
RedisServerCommands.dbsize()
-
keys
Find all keys matching the given pattern on all cluster upstream nodes.- Specified by:
keysin interfaceRedisKeyCommands<K,V>- Parameters:
pattern- the pattern type: patternkey (pattern)- Returns:
- List<K> array-reply list of keys matching
pattern. - See Also:
RedisKeyCommands.keys(Object)
-
keys
Find all keys matching the given pattern on all cluster upstream nodes.- Specified by:
keysin interfaceRedisKeyCommands<K,V>- Parameters:
channel- the channelpattern- the pattern- Returns:
- Long array-reply list of keys matching
pattern. - See Also:
RedisKeyCommands.keys(KeyStreamingChannel, Object)
-
randomkey
K randomkey()Return a random key from the keyspace on a random master.- Specified by:
randomkeyin interfaceRedisKeyCommands<K,V>- Returns:
- K bulk-string-reply the random key, or
nullwhen the database is empty. - See Also:
RedisKeyCommands.randomkey()
-
scriptFlush
String scriptFlush()Remove all the scripts from the script cache on all cluster nodes.- Specified by:
scriptFlushin interfaceRedisScriptingCommands<K,V>- Returns:
- String simple-string-reply
- See Also:
RedisScriptingCommands.scriptFlush()
-
scriptKill
String scriptKill()Kill the script currently in execution on all cluster nodes. This call does not fail even if no scripts are running.- Specified by:
scriptKillin interfaceRedisScriptingCommands<K,V>- Returns:
- String simple-string-reply, always OK.
- See Also:
RedisScriptingCommands.scriptKill()
-
shutdown
void shutdown(boolean save)Synchronously save the dataset to disk and then shut down all nodes of the cluster.- Specified by:
shutdownin interfaceRedisServerCommands<K,V>- Parameters:
save-trueforce save operation- See Also:
RedisServerCommands.shutdown(boolean)
-
scan
KeyScanCursor<K> scan()Incrementally iterate the keys space over the whole Cluster.- Specified by:
scanin interfaceRedisKeyCommands<K,V>- Returns:
- KeyScanCursor<K> scan cursor.
- See Also:
RedisKeyCommands.scan()
-
scan
Incrementally iterate the keys space over the whole Cluster.- Specified by:
scanin interfaceRedisKeyCommands<K,V>- Parameters:
scanArgs- scan arguments- Returns:
- KeyScanCursor<K> scan cursor.
- See Also:
RedisKeyCommands.scan(ScanArgs)
-
scan
Incrementally iterate the keys space over the whole Cluster.- Specified by:
scanin interfaceRedisKeyCommands<K,V>- Parameters:
scanCursor- cursor to resume the scan. It's required to reuse thescanCursorinstance from the previousscan()call.scanArgs- scan arguments- Returns:
- KeyScanCursor<K> scan cursor.
- See Also:
RedisKeyCommands.scan(ScanCursor, ScanArgs)
-
scan
Incrementally iterate the keys space over the whole Cluster.- Specified by:
scanin interfaceRedisKeyCommands<K,V>- Parameters:
scanCursor- cursor to resume the scan. It's required to reuse thescanCursorinstance from the previousscan()call.- Returns:
- KeyScanCursor<K> scan cursor.
- See Also:
RedisKeyCommands.scan(ScanCursor)
-
scan
Incrementally iterate the keys space over the whole Cluster.- Specified by:
scanin interfaceRedisKeyCommands<K,V>- Parameters:
channel- streaming channel that receives a call for every key- Returns:
- StreamScanCursor scan cursor.
- See Also:
RedisKeyCommands.scan(KeyStreamingChannel)
-
scan
Incrementally iterate the keys space over the whole Cluster.- Specified by:
scanin interfaceRedisKeyCommands<K,V>- Parameters:
channel- streaming channel that receives a call for every keyscanArgs- scan arguments- Returns:
- StreamScanCursor scan cursor.
- See Also:
RedisKeyCommands.scan(KeyStreamingChannel, ScanArgs)
-
scan
Incrementally iterate the keys space over the whole Cluster.- Specified by:
scanin interfaceRedisKeyCommands<K,V>- Parameters:
channel- streaming channel that receives a call for every keyscanCursor- cursor to resume the scan. It's required to reuse thescanCursorinstance from the previousscan()call.scanArgs- scan arguments- Returns:
- StreamScanCursor scan cursor.
- See Also:
RedisKeyCommands.scan(KeyStreamingChannel, ScanCursor, ScanArgs)
-
scan
Incrementally iterate the keys space over the whole Cluster.- Specified by:
scanin interfaceRedisKeyCommands<K,V>- Parameters:
channel- streaming channel that receives a call for every keyscanCursor- cursor to resume the scan. It's required to reuse thescanCursorinstance from the previousscan()call.- Returns:
- StreamScanCursor scan cursor.
- See Also:
RedisKeyCommands.scan(ScanCursor, ScanArgs)
-
touch
Touch one or more keys with pipelining. Touch sets the last accessed time for a key. Non-exsitent keys wont get created. Cross-slot keys will result in multiple calls to the particular cluster nodes.- Specified by:
touchin interfaceRedisKeyCommands<K,V>- Parameters:
keys- the keys- Returns:
- Long integer-reply the number of found keys.
-
upstream().