ketama consistent hashing in cython
Project description
pyketama
========
![build](https://img.shields.io/travis/maralla/pyketama.svg)
pyketama is a cython implementation of ketama consistent hashing algorithm.
Install
=======
```bash
pip install pyketama
```
Usage
=====
```python
import ketama
data = ["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'])
```
========
![build](https://img.shields.io/travis/maralla/pyketama.svg)
pyketama is a cython implementation of ketama consistent hashing algorithm.
Install
=======
```bash
pip install pyketama
```
Usage
=====
```python
import ketama
data = ["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'])
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyketama-0.2.1.tar.gz
(37.3 kB
view details)
File details
Details for the file pyketama-0.2.1.tar.gz
.
File metadata
- Download URL: pyketama-0.2.1.tar.gz
- Upload date:
- Size: 37.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e05502714ec06076e03745a96f1656fa369f8cc384d9e1147d9e540c082d04c |
|
MD5 | 95212fb65714cadc345c78bb722687b8 |
|
BLAKE2b-256 | 2c5a095dc1543a0607d98b7dc6d495c3af548847f4da76d979c7c30c784ac724 |