Class: Gelatin::Ring
Overview
Defines the hasher class arxiv.org/pdf/1406.2294.pdf
Instance Method Summary collapse
- #add(node) ⇒ Object
- #delete(node) ⇒ Object
-
#get(key) ⇒ Object
Key should be some sort of information about the object.
-
#initialize ⇒ Ring
constructor
A new instance of Ring.
Methods included from Jch
Constructor Details
#initialize ⇒ Ring
Returns a new instance of Ring.
9 10 11 |
# File 'lib/gelatin/ring.rb', line 9 def initialize @nodes = [] end |
Instance Method Details
#add(node) ⇒ Object
13 14 15 |
# File 'lib/gelatin/ring.rb', line 13 def add(node) @nodes << node end |
#delete(node) ⇒ Object
17 18 19 |
# File 'lib/gelatin/ring.rb', line 17 def delete(node) @nodes.delete node end |
#get(key) ⇒ Object
Key should be some sort of information about the object. If it’s a file, maybe you could use its relative path. If the object can fit in a uint64, you could use the object itself as the key.
25 26 27 |
# File 'lib/gelatin/ring.rb', line 25 def get(key) @nodes[hash(Zlib::crc32(key), @nodes.size)] end |