class ActiveRecord::ShardFor::HashModuloRouter

Public Instance Methods

route(key) click to toggle source

@param [String] key sharding key

# File lib/activerecord/shard_for/hash_modulo_router.rb, line 7
def route(key)
  hash(key) % connection_count
end

Private Instance Methods

hash(v) click to toggle source
# File lib/activerecord/shard_for/hash_modulo_router.rb, line 13
def hash(v)
  Zlib.crc32(v.to_s)
end