Skip to content

Commit

Permalink
Well thats about it folks.
Browse files Browse the repository at this point in the history
  • Loading branch information
3rd-Eden committed Apr 21, 2011
1 parent 5dffb00 commit bc68b81
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion README.md
Expand Up @@ -52,4 +52,30 @@ I have chosen crc32 as default algorithm because a creates a nice dense ring dis


### Small API ### Small API


In these examples I assume that you already setup a `hashring` instance, with the variable name `ring` like I did the in the examples illustrated above. In these examples I assume that you already setup a `hashring` instance, with the variable name `ring` like I did the in the examples illustrated above.

**Getting a node by key**
a.k.a key -> node look up, this is where all the magic is happening.

``` javascript
ring.getNode('foo'); // => '192.168.0.104:11212'
ring.getNode('pewpew'); // => '192.168.0.103:11212'
```

**Replacing a server**
If you are experiencing downtime with one of your servers, you might want to `hot swap` with a new server.

``` javascript
ring.replaceServer('192.168.0.104:11212','192.168.0.112:11212');
ring.getNode('foo'); // => '192.168.0.112:11212'
```

**Add server**
Adds a new server to the hash ring, but please note that this could cause a shift in current key -> server distribution.

``` javascript
ring.addServer('192.168.0.102:11212');
```


For a more extensive documentation: http://3rd-eden.github.com/node-hashring/

0 comments on commit bc68b81

Please sign in to comment.