About hash_ring
Implements consistent hashing that can be used when the number of server nodes can increase or decrease (like in memcached). The hashing ring is built using the same algorithm as libketama.
Consistent hashing is a scheme that provides a hash table functionality in a way that the adding or removing of one slot does not significantly change the mapping of keys to slots.
More about hash_ring can be read in a blog post (that explains the idea in greater details):
Consistent hashing implemented simply in python <http://amix.dk/blog/viewEntry/19367>
More information about consistent hashing can be read in these articles:
Web Caching with Consistent Hashing <http://www8.org/w8-papers/2a-webserver/caching/paper2.html>
Consistent hashing and random trees <http://citeseerx.ist.psu.edu/legacymapper?did=38148>
There is also a wrapper MemcacheRing that extends python-memcache to use consistent hashing for key distribution.
Example
Basic example of usage (for managing memcached instances):
memcache_servers = ['192.168.0.246:11212',
'192.168.0.247:11212',
'192.168.0.249:11212']
ring = HashRing(memcache_servers)
server = ring.get_node('my_key')
Example using weights:
memcache_servers = ['192.168.0.246:11212',
'192.168.0.247:11212',
'192.168.0.249:11212']
weights = {
'192.168.0.246:11212': 1,
'192.168.0.247:11212': 2,
'192.168.0.249:11212': 1
}
ring = HashRing(memcache_servers, weights)
server = ring.get_node('my_key')
How to use MemcacheRing:
from hash_ring import MemcacheRing
mc = MemcacheRing(['127.0.0.1:11212'])
mc.set('hello', 'world')
print mc.get('hello')
The code should be clean and simple. Feel free to concat the author if you detect bugs.
Metadata
Release files for hash_ring 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hash_ring-1.3.1.tar.gz | 4.0 kB | Without provenance | Details for hash_ring-1.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hash_ring-1.3.1-py2.7.egg | Legacy Egg format | - | - | Details for hash_ring-1.3.1-py2.7.egg |
Total release size: 12.3 kB
Release files / hash_ring-1.3.1.tar.gz
| Download URL | hash_ring-1.3.1.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f86b96517bc5cb7dbf34bbbc51cdd5968170877b43bc1ab7c9eb39345cff4dd7
|
|
BLAKE2b-256 checksum How to use checksums |
32f1798501920f7043d93707ccd902e7d9a0cfb68efc8d8051c16a3f8ee6c64f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / hash_ring-1.3.1-py2.7.egg
| Download URL | hash_ring-1.3.1-py2.7.egg |
|---|---|
| Size | 8.4 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
67b05e6c753a982cda85e4b1c010493b159e53ab112c3ac3b1c8fb6734f050d7
|
|
BLAKE2b-256 checksum How to use checksums |
480d070787770ee36992a37caaeb32135aec27756f8e15f1cef7a316d0af9bec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for hash_ring 1.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.