2017 © Pedro Peláez
 

project hashring

Consistent hashing "hashring" implementation in php (using the same algorithm as libketama)

image

chxj1992/hashring

Consistent hashing "hashring" implementation in php (using the same algorithm as libketama)

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 41 % Grown

The README.md

HashRing Build Status

WTFPL, (*1)

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., (*2)

Inspired by a golang hashring library serialx/hashring., (*3)

Using

Install ::, (*4)

composer require chxj1992/hashring:~1.0

Basic example usage ::, (*5)

$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 ::, (*6)

$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 ::, (*7)

$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");

The Versions

10/02 2018

dev-master

9999999-dev

Consistent hashing "hashring" implementation in php (using the same algorithm as libketama)

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

php consistent hashing libketama

19/02 2017

v1.0.1

1.0.1.0

Consistent hashing "hashring" implementation in php (using the same algorithm as libketama)

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

php consistent hashing libketama

19/02 2017

v1.0.0

1.0.0.0

Consistent hashing "hashring" implementation in php (using the same algorithm as libketama)

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

php consistent hashing libketama