kedama

Description

kedama is ruby port of the libketama.

libketama is a consistent hashing library.

see bit.ly/dVIeGh

Install

gem install kedama

Example

require 'kedama'

nodes = Kedama::Nodes.new
nodes.add('1.2.3.4:11211',  900)
nodes.add('5.6.7.8:11211',  300)
nodes.add('9.8.7.6:11211', 1500)

hash = nodes.to_h

10.times do |i|
  i = i.to_s
  puts i + "\t" + hash[i]
end

puts '---'

nodes.delete('5.6.7.8:11211')

hash = nodes.to_h

10.times do |i|
  i = i.to_s
  puts i + "\t" + hash[i]
end