Repository is archived
No commit activity in last 3 years
No release in over 3 years
hash_ring implementation in Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

hash_ring¶ ↑

Background¶ ↑

hash_ring is a pure Ruby implementation of consistent hashing. hash_ring is based on the original Python code written by Amir Salihefendic. A comprehensive blog post detailing the methods and reasoning for such a library can be viewed by visiting the following URL:

amix.dk/blog/viewEntry/19367

Usage¶ ↑

require 'rubygems'
require 'hash_ring'

memcache_servers = ['192.168.0.111:14107',
                    '192.168.0.112:14107',
                    '192.168.0.113:14108']

# Since server 1 has double the RAM, lets weight it
# twice as much to get twice the keys. This is optional
weights = { '192.168.0.111' => 2 }

ring = HashRing.new(memcache_servers, weights)
server = ring.get_node('my_key')

Installation¶ ↑

sudo gem install mitchellh-hash_ring