chxj1992/hashring
最新稳定版本:v1.0.1
Composer 安装命令:
composer create-project chxj1992/hashring
包简介
Consistent hashing "hashring" implementation in php (using the same algorithm as libketama)
README 文档
README
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.
Inspired by a golang hashring library serialx/hashring.
Using
Install ::
composer require chxj1992/hashring:~1.0
Basic example usage ::
$memcacheServers = ["192.168.0.246:11212", "192.168.0.247:11212", "192.168.0.249:11212"]; $hashRing = new \Chxj1992\HashRing\HashRing($memcacheServers); $server = $ring->getNode("my_key");
Using weights example ::
$weights = ["192.168.0.246:11212" => 1, "192.168.0.247:11212" => 2, "192.168.0.249:11212" => 1]; $hashRing = new \Chxj1992\HashRing\HashRing($weights); $server = $hashRing->getNode("my_key");
Adding and removing nodes example ::
$memcacheServers = ["192.168.0.246:11212", "192.168.0.247:11212", "192.168.0.249:11212"]; $hashRing = new \Chxj1992\HashRing\HashRing($memcacheServers); $hashRing = $hashRing->removeNode("192.168.0.246:11212"); $hashRing = $hashRing->addNode("192.168.0.250:11212"); $server = $hashRing->getNode("my_key");
统计信息
- 总下载量: 71.49k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-02-19