PHP code example of yiranzai / dht
1. Go to this page and download the library: Download yiranzai/dht library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yiranzai / dht example snippets
$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');
$hash = new Yiranzai\Dht\Dht();
$hash->deleteEntityNode('db_server_one');
$hash = new Yiranzai\Dht\Dht();
$hash->algo('sha256');
//or
$hash = new Yiranzai\Dht\Dht(['algo' => YOUR_ALGO]);