Class ClusterSlotHashUtil

java.lang.Object
org.springframework.data.redis.connection.ClusterSlotHashUtil

public abstract class ClusterSlotHashUtil extends Object
Utility class encapsulating functionality commonly used for cluster slot hashing.
Since:
1.7
Author:
Christoph Strobl, John Blum
  • Field Details

  • Constructor Details

    • ClusterSlotHashUtil

      public ClusterSlotHashUtil()
  • Method Details

    • isSameSlotForAllKeys

      public static boolean isSameSlotForAllKeys(byte[]... keys)
      Determines whether all keys will hash to the same slot.
      Parameters:
      keys - array of keys to evaluate3; must not be null.
      Returns:
      a boolean value indicating whether all keys will hash to the same slot.
      Throws:
      IllegalArgumentException - if the byte array of keys is null.
    • isSameSlotForAllKeys

      public static boolean isSameSlotForAllKeys(ByteBuffer... keys)
      Determines whether all keys will hash to the same slot.
      Parameters:
      keys - array of ByteBuffer objects containing the keys to evaluate; must not be null.
      Returns:
      a boolean value indicating whether all keys will hash to the same slot.
      Throws:
      IllegalArgumentException - if the array of keys is null.
      Since:
      2.0
      See Also:
    • isSameSlotForAllKeys

      public static boolean isSameSlotForAllKeys(Collection<ByteBuffer> keys)
      Determines whether all keys will hash to the same slot.
      Parameters:
      keys - Collection of ByteBuffer objects containing the keys to evaluate; must not be null.
      Returns:
      a boolean value indicating whether all keys will hash to the same slot.
      Throws:
      IllegalArgumentException - if the Collection of keys is null.
      Since:
      2.0
    • calculateSlot

      public static int calculateSlot(String key)
      Calculate the slot from the given key.
      Parameters:
      key - String containing the Redis key to evaluate; must not be null or empty.
      Returns:
      the computed slot based on the given key.
      Throws:
      IllegalArgumentException - if the given key is null or empty.
      See Also:
    • calculateSlot

      public static int calculateSlot(byte[] key)
      Calculate the slot from the given key.
      Parameters:
      key - array of bytes containing the Redis key to evaluate; must not be null.
      Returns:
      the computed slot based on the given key.