Class: RedisRing::Client::Sharder

Inherits:
Object
  • Object
show all
Defined in:
lib/redis_ring/client/sharder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metadata) ⇒ Sharder

Returns a new instance of Sharder.



8
9
10
# File 'lib/redis_ring/client/sharder.rb', line 8

def initialize()
  @metadata = 
end

Instance Attribute Details

#metadataObject (readonly)

Returns the value of attribute metadata.



6
7
8
# File 'lib/redis_ring/client/sharder.rb', line 6

def 
  @metadata
end

Instance Method Details

#shard_for_key(key) ⇒ Object



12
13
14
15
# File 'lib/redis_ring/client/sharder.rb', line 12

def shard_for_key(key)
  crc = Zlib.crc32(hashable_part(key.to_s))
  return crc % .ring_size
end