Module lettuce.core

Interface RedisClusterReactiveCommands<K,​V>

Type Parameters:
K - Key type.
V - Value type.
All Superinterfaces:
BaseRedisReactiveCommands<K,​V>, RedisAclReactiveCommands<K,​V>, RedisGeoReactiveCommands<K,​V>, RedisHashReactiveCommands<K,​V>, RedisHLLReactiveCommands<K,​V>, RedisKeyReactiveCommands<K,​V>, RedisListReactiveCommands<K,​V>, RedisScriptingReactiveCommands<K,​V>, RedisServerReactiveCommands<K,​V>, RedisSetReactiveCommands<K,​V>, RedisSortedSetReactiveCommands<K,​V>, RedisStreamReactiveCommands<K,​V>, RedisStringReactiveCommands<K,​V>
All Known Subinterfaces:
RedisAdvancedClusterReactiveCommands<K,​V>, RedisClusterPubSubReactiveCommands<K,​V>, RedisPubSubReactiveCommands<K,​V>, RedisReactiveCommands<K,​V>
All Known Implementing Classes:
AbstractRedisReactiveCommands, RedisAdvancedClusterReactiveCommandsImpl, RedisClusterPubSubReactiveCommandsImpl, RedisPubSubReactiveCommandsImpl, RedisReactiveCommandsImpl, RedisSentinelReactiveCommandsImpl

public interface RedisClusterReactiveCommands<K,​V>
extends BaseRedisReactiveCommands<K,​V>, RedisAclReactiveCommands<K,​V>, RedisGeoReactiveCommands<K,​V>, RedisHashReactiveCommands<K,​V>, RedisHLLReactiveCommands<K,​V>, RedisKeyReactiveCommands<K,​V>, RedisListReactiveCommands<K,​V>, RedisScriptingReactiveCommands<K,​V>, RedisServerReactiveCommands<K,​V>, RedisSetReactiveCommands<K,​V>, RedisSortedSetReactiveCommands<K,​V>, RedisStreamReactiveCommands<K,​V>, RedisStringReactiveCommands<K,​V>
A complete reactive and thread-safe cluster Redis API with 400+ Methods.
Since:
5.0
Author:
Mark Paluch
  • Method Details

    • setTimeout

      void setTimeout​(Duration timeout)
      Set the default timeout for operations. A zero timeout value indicates to not time out.
      Parameters:
      timeout - the timeout value
      Since:
      5.0
    • auth

      Mono<String> auth​(CharSequence password)
      Authenticate to the server.
      Parameters:
      password - the password
      Returns:
      String simple-string-reply
    • auth

      Mono<String> auth​(String username, CharSequence password)
      Authenticate to the server with username and password. Requires Redis 6 or newer.
      Parameters:
      username - the username
      password - the password
      Returns:
      String simple-string-reply
      Since:
      6.0
    • clusterBumpepoch

      Mono<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

      Mono<String> clusterMeet​(String ip, int port)
      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 host
      port - port number.
      Returns:
      String simple-string-reply
    • clusterForget

      Mono<String> clusterForget​(String nodeId)
      Disallow connections and remove the cluster node from the cluster.
      Parameters:
      nodeId - the node Id
      Returns:
      String simple-string-reply
    • clusterAddSlots

      Mono<String> clusterAddSlots​(int... slots)
      Adds slots to the cluster node. The current node will become the master for the specified slots.
      Parameters:
      slots - one or more slots from 0 to 16384
      Returns:
      String simple-string-reply
    • clusterDelSlots

      Mono<String> clusterDelSlots​(int... slots)
      Removes slots from the cluster node.
      Parameters:
      slots - one or more slots from 0 to 16384
      Returns:
      String simple-string-reply
    • clusterSetSlotNode

      Mono<String> clusterSetSlotNode​(int slot, String nodeId)
      Assign a slot to a node. The command migrates the specified slot from the current node to the specified node in nodeId
      Parameters:
      slot - the slot
      nodeId - the id of the node that will become the master for the slot
      Returns:
      String simple-string-reply
    • clusterSetSlotStable

      Mono<String> clusterSetSlotStable​(int slot)
      Clears migrating / importing state from the slot.
      Parameters:
      slot - the slot
      Returns:
      String simple-string-reply
    • clusterSetSlotMigrating

      Mono<String> clusterSetSlotMigrating​(int slot, String nodeId)
      Flag a slot as MIGRATING (outgoing) towards the node specified in nodeId. The slot must be handled by the current node in order to be migrated.
      Parameters:
      slot - the slot
      nodeId - the id of the node is targeted to become the master for the slot
      Returns:
      String simple-string-reply
    • clusterSetSlotImporting

      Mono<String> clusterSetSlotImporting​(int slot, String nodeId)
      Flag a slot as IMPORTING (incoming) from the node specified in nodeId.
      Parameters:
      slot - the slot
      nodeId - the id of the node is the master of the slot
      Returns:
      String simple-string-reply
    • clusterInfo

      Mono<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

      Mono<String> clusterMyId()
      Obtain the nodeId for the currently connected node.
      Returns:
      String simple-string-reply
    • clusterNodes

      Mono<String> clusterNodes()
      Obtain details about all cluster nodes. Can be parsed using ClusterPartitionParser.parse(java.lang.String)
      Returns:
      String bulk-string-reply as a collection of text lines
    • clusterSlaves

      Flux<String> clusterSlaves​(String nodeId)
      List replicas for a certain node identified by its nodeId. Can be parsed using ClusterPartitionParser.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

      Flux<K> clusterGetKeysInSlot​(int slot, int count)
      Retrieve the list of keys within the slot.
      Parameters:
      slot - the slot
      count - maximal number of keys
      Returns:
      List<K> array-reply list of keys
    • clusterCountKeysInSlot

      Mono<Long> clusterCountKeysInSlot​(int slot)
      Returns the number of keys in the specified Redis Cluster hash slot.
      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

      Mono<Long> clusterCountFailureReports​(String nodeId)
      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

      Mono<Long> clusterKeyslot​(K key)
      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 as SlotHash.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

      Mono<String> clusterSaveconfig()
      Forces a node to save the nodes.conf configuration on disk.
      Returns:
      String simple-string-reply: OK or an error if the operation fails.
    • clusterSetConfigEpoch

      Mono<String> clusterSetConfigEpoch​(long configEpoch)
      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: OK or an error if the operation fails.
    • clusterSlots

      Flux<Object> clusterSlots()
      Get array of cluster slots to node mappings.
      Returns:
      List<Object> array-reply nested list of slot ranges with IP/Port mappings.
    • asking

      Mono<String> asking()
      The asking command is required after a -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.
      Returns:
      String simple-string-reply
    • clusterReplicate

      Mono<String> clusterReplicate​(String nodeId)
      Turn this node into a replica of the node with the id nodeId.
      Parameters:
      nodeId - master node id
      Returns:
      String simple-string-reply
    • clusterFailover

      Mono<String> clusterFailover​(boolean force)
      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 if true
      Returns:
      String simple-string-reply
    • clusterReset

      Mono<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
      Parameters:
      hard - true for hard reset. Generates a new nodeId and currentEpoch/configEpoch are set to 0
      Returns:
      String simple-string-reply
    • clusterFlushslots

      Mono<String> clusterFlushslots()
      Delete all the slots associated with the specified node. The number of deleted slots is returned.
      Returns:
      String simple-string-reply
    • readOnly

      Mono<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:
      readOnly in interface BaseRedisReactiveCommands<K,​V>
      Returns:
      String simple-string-reply
    • readWrite

      Mono<String> readWrite()
      Resets readOnly flag.
      Specified by:
      readWrite in interface BaseRedisReactiveCommands<K,​V>
      Returns:
      String simple-string-reply
    • del

      Mono<Long> del​(K... keys)
      Delete a key with pipelining. Cross-slot keys will result in multiple calls to the particular cluster nodes.
      Specified by:
      del in interface RedisKeyReactiveCommands<K,​V>
      Parameters:
      keys - the key
      Returns:
      Flux<Long> integer-reply The number of keys that were removed.
    • mget

      Flux<KeyValue<K,​V>> mget​(K... keys)
      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:
      mget in interface RedisStringReactiveCommands<K,​V>
      Parameters:
      keys - the key
      Returns:
      Flux<List<V>> array-reply list of values at the specified keys.
    • mset

      Mono<String> mset​(Map<K,​V> map)
      Set multiple keys to multiple values with pipelining. Cross-slot keys will result in multiple calls to the particular cluster nodes.
      Specified by:
      mset in interface RedisStringReactiveCommands<K,​V>
      Parameters:
      map - the null
      Returns:
      Flux<String> simple-string-reply always OK since MSET can't fail.
    • msetnx

      Mono<Boolean> msetnx​(Map<K,​V> map)
      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:
      msetnx in interface RedisStringReactiveCommands<K,​V>
      Parameters:
      map - the null
      Returns:
      Flux<Boolean> integer-reply specifically: 1 if the all the keys were set. 0 if no key was set (at least one key already existed).