public class SlotHash extends Object
Modifier and Type | Field and Description |
---|---|
static int |
SLOT_COUNT
Number of redis cluster slot hashes.
|
static byte |
SUBKEY_END
Constant for a subkey end.
|
static byte |
SUBKEY_START
Constant for a subkey start.
|
Modifier and Type | Method and Description |
---|---|
static int |
getSlot(byte[] key)
Calculate the slot from the given key.
|
static int |
getSlot(ByteBuffer key)
Calculate the slot from the given key.
|
static int |
getSlot(String key)
Calculate the slot from the given key.
|
static <S extends Number,K> |
getSlots(Map<S,? extends Iterable<K>> partitioned)
Create mapping between the Key and hash slot.
|
static <K,V> Map<Integer,List<K>> |
partition(RedisCodec<K,V> codec,
Iterable<K> keys)
Partition keys by slot-hash.
|
public static final byte SUBKEY_START
public static final byte SUBKEY_END
public static final int SLOT_COUNT
public static int getSlot(String key)
key
- the keypublic static int getSlot(byte[] key)
key
- the keypublic static int getSlot(ByteBuffer key)
key
- the keypublic static <K,V> Map<Integer,List<K>> partition(RedisCodec<K,V> codec, Iterable<K> keys)
K
- Key type.V
- Value type.codec
- codec to encode the key.keys
- iterable of keys.public static <S extends Number,K> Map<K,S> getSlots(Map<S,? extends Iterable<K>> partitioned)
K
- key typeS
- slot-hash number type.partitioned
- map partitioned by slot-hash and keys.Copyright © 2025 lettuce.io. All rights reserved.