-
Notifications
You must be signed in to change notification settings - Fork 0
/
PKG-INFO
58 lines (44 loc) · 2.26 KB
/
PKG-INFO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Metadata-Version: 1.0
Name: consistent_hash
Version: 1.0
Summary: Implements consistent hashing with Python and the algorithm is the same as libketama.
Home-page: https://github.com/yummybian
Author: Yummy Bian
Author-email: yummy.bian#gmail.com
License: BSD
Description: consistent-hash
===============
Implements consistent hashing that can be used when the number of server nodes can increase or decrease.The algorithm that is used for consistent hashing is the same as libketama <https://github.com/RJ/ketama>
Usage
===============
It's so easy to use^_^::
from consistent_hash import ConsistentHash
# You can construct consistent hash with the below three ways
con_hash = ConsistentHash({'192.168.0.101:11212':1, '192.168.0.102:11212':2, '192.168.0.103:11212':1})
# Or
con_hash = ConsistentHash(['192.168.0.101:11212', '192.168.0.102:11212', '192.168.0.103:11212']))
# Or
con_hash = ConsistentHash('192.168.0.101:11212')
# Add servers to hash ring
con_hash.add_nodes({'192.168.0.104:11212':1})
# Get a server via the key of object
server = con_hash.get_node('my_key')
# Delete the server from hash ring, you don't need to indicate weights
con_hash.del_nodes(['192.168.0.102:11212', '192.168.0.104:11212'])
Unit test
===============
- Firstly, install nose which extends unittest to make testing easier::
pip install nose
- Then, run tests::
# Option -s any stdout output will be printed immediately
# and -v be more verbose
nosetests -s -v
More information about nose <https://nose.readthedocs.org/en/latest/>
Keywords: consistent hash hashing
Platform: Any
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Libraries :: Python Modules