Class: RedisCluster::Slot
- Inherits:
-
Object
- Object
- RedisCluster::Slot
- Defined in:
- lib/redis_cluster/slot.rb
Constant Summary collapse
- KEY_PATTERN =
/\{([^\}]*)\}/
Class Method Summary collapse
-
.slot_by(key) ⇒ Object
key “xxxooo” will calculate “xxx” for slot if key is “{}dddd”, calculate “{}dddd” for slot.
Class Method Details
.slot_by(key) ⇒ Object
key “xxxooo” will calculate “xxx” for slot if key is “{}dddd”, calculate “{}dddd” for slot
8 9 10 11 12 13 |
# File 'lib/redis_cluster/slot.rb', line 8 def self.slot_by(key) key = key.to_s KEY_PATTERN =~ key key = $1 if $1 && !$1.empty? CRC16.crc16(key) % Configuration::HASH_SLOTS end |