2017 © Pedro Peláez
 

library consistent-hash

a consistent hash library implemented by PHP

image

out001a/consistent-hash

a consistent hash library implemented by PHP

  • Friday, June 30, 2017
  • by out001a
  • Repository
  • 1 Watchers
  • 1 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

consistent hash

https://packagist.org/packages/out001a/consistent-hash, (*1)

Usage

$ composer require out001a/consistent-hash
require 'vendor/autoload.php';

use Out001a\ConsistentHash;

$chash = new ConsistentHash('test');

// 增加节点
$chash->addNode('127.0.0.1:80');
$chash->addNode('127.0.0.1:81');
$chash->addNode('127.0.0.1:82');

// 查找字符串哈希到的节点
var_dump('abc -> '.$chash->lookup('abc'));
var_dump('def -> '.$chash->lookup('def'));
var_dump('ghi -> '.$chash->lookup('ghi'));

echo "\n========\n\n";

// 删除某个节点
$chash->removeNode('127.0.0.1:82');

// 再次查找节点
var_dump('abc -> '.$chash->lookup('abc'));
var_dump('def -> '.$chash->lookup('def'));
var_dump('ghi -> '.$chash->lookup('ghi'));

The Versions

30/06 2017

dev-master

9999999-dev

a consistent hash library implemented by PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

by Avatar out001a

03/06 2017

1.1

1.1.0.0

a consistent hash library implemented by PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

by Avatar out001a