Skip to content

mau21mau/python-ketama

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-ketama for memcached client.

This repo is an implementation example of Ketama consistent hash algorithm with Python, for the Python memcached client. This implementation aims to allow adding nodes of memcached server at runtime. If you want to understand a bit more about the issues around the consistent hashing, these are some good references:

  1. custom_memcached.py
    • Holds the implementation of a memcache.Client subclass called CustomMemcacheClient.
  2. consistent_hash.py
    • Holds the implementation of the consistent hash algorithm for ketama. The class is called HashRing and it is an adaptation from Amir Salihefendic HashRing python class.
  3. test.py
    • Holds a simple test script that uses the CustomMemcacheClient. To run the test you just need to make sure that you have the memcache manager and python-memcached client module installed.

To install the memcached and memcached run the following commands:

memcached:

sudo apt-get install memcached

python-memcached:

pip install python-memcached

After install Memcached you just need to run the "test.py" on the terminal. If you want to specify the algorithm to test you have to pass it as parameter like this:

To test KETAMA:

python test.py -k

To test MODULO (the default algorithm used by the original memcache.Client superclass):

python test.py -m

If you don't specify any argument it will take KETAMA by default.

About

Implementation of Ketama consistent hash algorithm with Python, for memcached

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages