Skip to content
PHP Distributed Hash Table, Suitable for assisting in finding distributed nodes corresponding to key. (You need to find a way to cache your node information.)
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.editorconfig
.gitattributes
.gitignore
.scrutinizer.yml
.styleci.yml
.travis.yml
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
ISSUE_TEMPLATE.md
LICENSE.md
PULL_REQUEST_TEMPLATE.md
README.md
SUPPORT_ALGOS.md
composer.json
phpcs.xml.dist
phpunit.xml.dist

README.md

php-dht

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

PHP Distributed Hash Table, Suitable for assisting in finding distributed nodes corresponding to key.

You have to cache it and pass it in the next time you use it.

Install

Via Composer

$ composer require yiranzai/dht

Usage

easy

init

$hash = new Yiranzai\Dht\Dht();
$hash->addEntityNode('db_server_one')->addEntityNode('db_server_two');
$dbServer =  $hash->getLocation('key_one');

//or

$dhtOne = new Yiranzai\Dht\Dht([
    'virtualNodeNum' => 3,
    'algo'           => 'sha256',
]);
$dhtOne->addEntityNode('db_server_one');

Reuse it

You have to cache it and pass it in the next time you use it.

$hash = new Yiranzai\Dht\Dht();
$hash->addEntityNode('db_server_one')->addEntityNode('db_server_two');
$dbServer =  $hash->getLocation('key_one');
$cache = $hash->toArray();
// please cache this data
$hash = new Yiranzai\Dht\Dht($cache);
$dbServer =  $hash->getLocation('key_one');

Delete Entity Node

Delete entity node

$hash = new Yiranzai\Dht\Dht();
$hash->deleteEntityNode('db_server_one');

Change algo

default algo is time33, See more support

$hash = new Yiranzai\Dht\Dht();
$hash->algo('sha256');

//or

$hash = new Yiranzai\Dht\Dht(['algo' => YOUR_ALGO]);

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email wuqingdzx@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

You can’t perform that action at this time.