PHP code example of runner / consistent-hash

1. Go to this page and download the library: Download runner/consistent-hash 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/ */

    

runner / consistent-hash example snippets




use Runner\ConsistentHash\ConsistentHash;

$hash = new ConsistentHash(
    [
            [
                'node' => 'node_1',
            ],
            [
                'node' => 'node_2',
                'weight' => 2,
            ],
            [
                'node' => 'node_3',
                'weight' => 3,
            ],
            [
                'node' => 'node_4',
                'weight' => 4,
            ],
            [
                'node' => 'node_5',
                'weight' => 5,
            ],
    ],
    'md5'
);

$node = $hash->lookup('RUNNERLEER');