Algorithm::ConsistentHash::CHash - XS bindings to bundled Consistent Hash library
my $ch = Algorithm::ConsistentHash::CHash->new( ids => [ 'server1', 'server2' ], replicas => 100, ); my $node = $ch->lookup('foo'); # $node is either server1 or server2, consistently
Consistent Hashing allows to spread data out across multiple IDs, ensuring relatively-even distribution using replicas. The more replicas, the better distribution (but lower performance).
Given a consistent hash, adding a node to the hash only requires reassigning a minimal number of keys.
A C implementation of the Consistent Hash algorithm is bundled in this package, along with the XS bindings to it. This might change in the future.
my $ch = Algorithm::ConsistentHash::CHash->new( ids => [ @nodes_names ], replicas => $number_of_replicas, );
Create a new Algorithm::ConsistentHash::CHash object. This internally generates a new hash.
my $node_name = $ch->lookup($key);
Looks up a node in the hash by the given key.
https://github.com/dgryski/libchash - The bundled C library.
Hash::ConsistentHash - Contains the entire logics in the XS, leading to it not being easily usable in other languages, and having a more complicated, alebit sophisticated, interface.
Set::ConsistentHash - Pure-Perl implementation.
Eric Herman <eric@freesa.org>
Sawyer X <xsawyerx@cpan.org>
Steffen Mueller <smueller@cpan.org>
To install Algorithm::ConsistentHash::CHash, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Algorithm::ConsistentHash::CHash
CPAN shell
perl -MCPAN -e shell install Algorithm::ConsistentHash::CHash
For more information on module installation, please visit the detailed CPAN module installation guide.