Name | py-consistent-hash JSON |
Version |
1.0.1
JSON |
| download |
home_page | None |
Summary | A consistent hash implementation in python |
upload_time | 2024-07-09 04:49:31 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | MIT License Copyright (c) 2024 Gaurav Tiwari Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
hash
consistent hash
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
### Consistent Hashing
Consistent hashing is used in distributed systems to efficiently distribute data among multiple nodes while minimizing reorganization when nodes are added or removed.It maps both data and nodes onto a common hash space (typically a circle), where each node is responsible for the data that falls within its range on the circle.
#### Features
1. This library use md5 from hashlib. Get the string value (hex digest) and convert it into a string
2. Two maps are maintained by this library
a. Map to identify the hash of nodes adding to the ring
b. Map to identify which keys are part of what nodes
#### Usage
```
consistent_hashing_impl = ConsistentHashingImpl()
consistent_hashing_impl.add_node("node1")
consistent_hashing_impl.add_node("node2")
consistent_hashing_impl.add_node("node3")
print("Key will be stored in node :%s" % consistent_hashing_impl.get_node_for_data("python"))
print("Key will be stored in node :%s" % consistent_hashing_impl.get_node_for_data("Java"))
```
The above code will generate the following output
```
2024-07-09 00:01:34,035: Generating hash for key: node1
2024-07-09 00:01:34,035: Generating hash for key: node2
2024-07-09 00:01:34,035: Generating hash for key: node3
2024-07-09 00:01:34,035: Generating hash for key: python
Key will be stored in node :node2
2024-07-09 00:01:34,035: Generating hash for key: Java
Key will be stored in node :node1
```
#### Installation
```pip install py-consistent-hash==1.0.0```
Raw data
{
"_id": null,
"home_page": null,
"name": "py-consistent-hash",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "hash, consistent hash",
"author": null,
"author_email": "Gaurav Tiwari <gtinside@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/67/90/86a9043ea155226f815b4e583575459aea9b8e9bc38bbdcfbe718f1e497e/py_consistent_hash-1.0.1.tar.gz",
"platform": null,
"description": "### Consistent Hashing\n\nConsistent hashing is used in distributed systems to efficiently distribute data among multiple nodes while minimizing reorganization when nodes are added or removed.It maps both data and nodes onto a common hash space (typically a circle), where each node is responsible for the data that falls within its range on the circle.\n\n#### Features\n1. This library use md5 from hashlib. Get the string value (hex digest) and convert it into a string\n2. Two maps are maintained by this library\n a. Map to identify the hash of nodes adding to the ring\n b. Map to identify which keys are part of what nodes\n\n#### Usage\n```\nconsistent_hashing_impl = ConsistentHashingImpl()\nconsistent_hashing_impl.add_node(\"node1\")\nconsistent_hashing_impl.add_node(\"node2\")\nconsistent_hashing_impl.add_node(\"node3\")\n\nprint(\"Key will be stored in node :%s\" % consistent_hashing_impl.get_node_for_data(\"python\"))\nprint(\"Key will be stored in node :%s\" % consistent_hashing_impl.get_node_for_data(\"Java\"))\n```\nThe above code will generate the following output\n```\n2024-07-09 00:01:34,035: Generating hash for key: node1\n2024-07-09 00:01:34,035: Generating hash for key: node2\n2024-07-09 00:01:34,035: Generating hash for key: node3\n2024-07-09 00:01:34,035: Generating hash for key: python\nKey will be stored in node :node2\n2024-07-09 00:01:34,035: Generating hash for key: Java\nKey will be stored in node :node1\n```\n\n#### Installation \n```pip install py-consistent-hash==1.0.0```\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 Gaurav Tiwari Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "A consistent hash implementation in python",
"version": "1.0.1",
"project_urls": {
"Homepage": "https://github.com/gtinside/consistent-hashing"
},
"split_keywords": [
"hash",
" consistent hash"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "dbe2c51041c3247d6c432440aa4adf62cf66d231e91d0086832d5eff3fdbbd25",
"md5": "d3a919405aa5bfb5439b3b1222e0a191",
"sha256": "69f79a6bc390b3b0daff86fc991d806bfc934afb1f2277d5e302ae7d86c976e5"
},
"downloads": -1,
"filename": "py_consistent_hash-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d3a919405aa5bfb5439b3b1222e0a191",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 4232,
"upload_time": "2024-07-09T04:49:30",
"upload_time_iso_8601": "2024-07-09T04:49:30.950803Z",
"url": "https://files.pythonhosted.org/packages/db/e2/c51041c3247d6c432440aa4adf62cf66d231e91d0086832d5eff3fdbbd25/py_consistent_hash-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "679086a9043ea155226f815b4e583575459aea9b8e9bc38bbdcfbe718f1e497e",
"md5": "1d71be40c3a16596984b61a6475aec57",
"sha256": "c53979004b06d4945aba632d55becc3e02d8f60c8143250ef59afc34809bc6c6"
},
"downloads": -1,
"filename": "py_consistent_hash-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "1d71be40c3a16596984b61a6475aec57",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 3586,
"upload_time": "2024-07-09T04:49:31",
"upload_time_iso_8601": "2024-07-09T04:49:31.960548Z",
"url": "https://files.pythonhosted.org/packages/67/90/86a9043ea155226f815b4e583575459aea9b8e9bc38bbdcfbe718f1e497e/py_consistent_hash-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-09 04:49:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gtinside",
"github_project": "consistent-hashing",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "py-consistent-hash"
}