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

mitchellh/hash_ring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Consistent hashing in Ruby. Ported from Amir Sailhefendic's hash_ring python library.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages