Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Latest commit

 

History

History
31 lines (21 loc) · 815 Bytes

README.rdoc

File metadata and controls

31 lines (21 loc) · 815 Bytes

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