-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Python bindings & libmemcached ketama compatibility #3
Add Python bindings & libmemcached ketama compatibility #3
Conversation
If compiling with LIBMEMCACHED_COMPAT, only the low 32 bits of the md5 hash will be used, and a "-" will be appended between the node name and the node index
This is great, thanks! I'll merge this and maybe add using libmemcached compatibility as a runtime option. What do you think? |
…541f9 Add Python bindings & libmemcached ketama compatibility
Runtime would be great—wasn't sure if it would be useful beyond our use-case (we have an existing pool that's libmemcached-hashed) so made it compile time but I think run-time would be cleaner than #ifdefs :) |
Okay I'll update that, maybe throw in a test too to ensure the compatibility. Is there a reason you chose to use hash-ring over ketama or libmemcached? |
Our app servers run Python, and pylibmc + libmemcached uses non-Python sockets and plays not-very-nicely with gevent's cooperative multithreading, so we're moving to ultramemcached, which is very fast but has no hash ring support. First i dropped in the python hash_ring module, but found that we were spending way too much time in Python doing the hashing / ring calculations, so moving that into C was the next step. I didn't like libketama's approach of reading its input from a file (the Python bindings for example create a temp file and .write() into it), and hash-ring was nicely self-contained, so went with that. Mike Krieger On Monday, December 26, 2011 at 5:03 PM, Chris Moos wrote:
|
Cool, thanks for the info and the contribution. I'm going to push the change for the option at runtime with hash_ring_set_mode() in a bit. Just need to update some bindings. |
Update README.md
Add blank priv directory
The Python bindings are written with ctypes and support adding, removing, printing, and finding nodes.
For libmemcached compatibility, their implementation of ketama only uses the lower 32 bits, and for the node name appends the position in the ring as "-index" instead of just "index". I made this a compile-time option.