Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maralla/pyketama
Ketama Consistent Hashing in Cython
https://github.com/maralla/pyketama
Last synced: 15 days ago
JSON representation
Ketama Consistent Hashing in Cython
- Host: GitHub
- URL: https://github.com/maralla/pyketama
- Owner: maralla
- License: bsd-2-clause
- Created: 2014-11-27T08:25:55.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-09-26T06:42:31.000Z (about 7 years ago)
- Last Synced: 2024-09-23T19:07:37.708Z (about 2 months ago)
- Language: C
- Size: 23.4 KB
- Stars: 18
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
pyketama
========
![build](https://img.shields.io/travis/maralla/pyketama.svg)
![version](https://img.shields.io/pypi/v/pyketama.svg)pyketama is a cython implementation of ketama consistent hashing algorithm.
Install
=======```bash
pip install pyketama
```Usage
=====```python
import ketamadata = ["127.0.0.1:12211", "127.0.0.1:12212"]
continuum = ketama.Continuum(data)
print(continuum['test'])# with weight, (key, weith)
data = [("127.0.0.1:12211", 400), ("127.0.0.1:12212", 500)]
continuum = ketama.Continuum(data)
print(continuum['test'])# with value, (key, value, weight)
data = [("node1", "127.0.0.1:12211", 400), ("node2", "127.0.0.1:12212", 500)]
continuum = ketama.Continuum(data)
print(continuum['test'])# set item like dict
continuum = ketama.Continuum()
continuum['tom'] = 123
continuum['jerry'] = "hello world"
print(continuum['test'])# with weight (key, weight)
continuum = ketama.Continuum()
continuum[('tom', 100)] = 123
continuum[('jerry', 300)] = "hello world"
print(continuum['test'])
```