Sha256: e79a591db7def7d1fb8b7255130e63392b6314ce17818754b2e28fac5d82ab24
Contents?: true
Size: 499 Bytes
Versions: 2
Compression:
Stored size: 499 Bytes
Contents
require 'digest/md5' module MixedGauge class Routing # @param [ClusterConfig] cluster_config def initialize(cluster_config) @cluster_config = cluster_config end # @param [String] dist_key # @return [String] connection name def route(key) slot = hash_f(key) % @cluster_config.slot_count @cluster_config.fetch(slot) end # @param [String] key # @return [Integer] def hash_f(key) Digest::MD5.hexdigest(key).to_i(16) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mixed_gauge-0.1.1 | lib/mixed_gauge/routing.rb |
mixed_gauge-0.1.0 | lib/mixed_gauge/routing.rb |