Interface RedisClusterConnection

All Superinterfaces:
AutoCloseable, DefaultedRedisClusterConnection, DefaultedRedisConnection, RedisClusterCommands, RedisClusterCommandsProvider, RedisClusterServerCommands, RedisCommands, RedisCommandsProvider, RedisConnection, RedisConnectionCommands, RedisGeoCommands, RedisHashCommands, RedisHyperLogLogCommands, RedisKeyCommands, RedisListCommands, RedisPubSubCommands, RedisScriptingCommands, RedisServerCommands, RedisSetCommands, RedisStreamCommands, RedisStringCommands, RedisTxCommands, RedisZSetCommands
All Known Implementing Classes:
JedisClusterConnection, LettuceClusterConnection

public interface RedisClusterConnection extends RedisConnection, DefaultedRedisClusterConnection, RedisClusterCommandsProvider
RedisClusterConnection allows sending commands to dedicated nodes within the cluster. A RedisClusterNode can be obtained from RedisClusterCommands.clusterGetNodes() or it can be constructed using either host and RedisNode.getPort() or the node Id.

Redis connections, unlike perhaps their underlying native connection are not Thread-safe and should not be shared across multiple threads.

Since:
1.7
Author:
Christoph Strobl, Mark Paluch
  • Method Details

    • ping

      @Nullable String ping(RedisClusterNode node)
      Parameters:
      node - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • keys

      @Nullable Set<byte[]> keys(RedisClusterNode node, byte[] pattern)
      Parameters:
      node - must not be null.
      pattern - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • scan

      Cursor<byte[]> scan(RedisClusterNode node, ScanOptions options)
      Use a Cursor to iterate over keys.
      Parameters:
      node - must not be null.
      options - must not be null.
      Returns:
      never null.
      Since:
      2.1
      See Also:
    • randomKey

      @Nullable byte[] randomKey(RedisClusterNode node)
      Parameters:
      node - must not be null.
      Returns:
      null when no keys stored at node or when used in pipeline / transaction.
      See Also:
    • execute

      @Nullable default <T> T execute(String command, byte[] key, Collection<byte[]> args)
      Execute the given command for the key provided potentially appending args.
      This method, other than RedisCommands.execute(String, byte[]...), dispatches the command to the key serving master node.
       
       // SET foo bar EX 10 NX
       execute("SET", "foo".getBytes(), asBinaryList("bar", "EX", 10, "NX"))
       
       
      Parameters:
      command - must not be null.
      key - must not be null.
      args - must not be null.
      Returns:
      command result as delivered by the underlying Redis driver. Can be null.
      Since:
      2.1