PHP Distributed Hash Table, Suitable for assisting in finding distributed nodes corresponding to key.
MIT License
PHP Distributed Hash Table, Suitable for assisting in finding distributed nodes corresponding to key.
Via Composer
$ composer require yiranzai/hash-dht
easy
$hash = new Yiranzai\Dht\Hash();
$hash->addEntityNode('db_server_one')->addEntityNode('db_server_two');
$dbServer = $hash->getLocation('key_one');
You have to cache it and pass it in the next time you use it.
Or use the static::cache
I provided.
$hash = new Yiranzai\Dht\Hash();
$hash->addEntityNode('db_server_one')->addEntityNode('db_server_two');
$dbServer = $hash->getLocation('key_one');
Yiranzai\Dht\Hash::cache($hash->toArray());
$hash = new Yiranzai\Dht\Hash(Yiranzai\Dht\Hash::getCache());
$dbServer = $hash->getLocation('key_one');
Delete entity node
$hash = new Yiranzai\Dht\Hash();
$hash->deleteEntityNode('db_server_one');
default algo is time33, See more support
$hash = new Yiranzai\Dht\Hash();
$hash->algo('sha256');
//or
$hash = new Yiranzai\Dht\Hash(['algo' => YOUR_ALGO]);
Change default cache path
$hash = new Yiranzai\Dht\Hash();
$hash->path(YOUR_PATH);
//or
$hash = new Yiranzai\Dht\Hash(['cachePath' => YOUR_PATH]);
Please see CHANGELOG for more information on what has changed recently.
$ composer test
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.