Class: RedisRing::Client::Sharder
- Inherits:
-
Object
- Object
- RedisRing::Client::Sharder
- Defined in:
- lib/redis_ring/client/sharder.rb
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
-
#initialize(metadata) ⇒ Sharder
constructor
A new instance of Sharder.
- #shard_for_key(key) ⇒ Object
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
#metadata ⇒ Object (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 |