ketama - a consistent hashing algo for memcache clients

Richard Jones rj at
Tue Apr 10 22:01:59 UTC 2007

> 	This is a very interesting idea, and I'd like to add a consistent
> hash driver to my java interface, but there's a bit of gap between
> your writeup and what the implementation.

Check the init() method - that builds up the appropriate data structure (a 
TreeMap called buckets iirc). You can use any hashing mechanism you want 
instead of the md5 thing, that just seemed a convenient way to generate a 
bunch of hashes. If you change it you won't be compatible with other 
implementations - not a problem if you are exclusively using java tho.

Once you've build the data structure using the servers list, that is pretty 
much it in java, just check how keys are mapped to servers in findPointFor().


> 	In the java interface, all I see is that you've added a new hash
> type that's based off an MD5.  Is that actually an important detail?
> It seems like you should be able to use any hash that produces an
> even 32-bits.
> 	Is it OK if I use your C implementation as a specification?

Richard Jones Ltd. |
Office: +44 (0) 207 780 7080
Mobile: +44 (0) 7740 194 389

More information about the memcached mailing list