PHP Класс Phan\Library\Hasher\Consistent

See https://en.wikipedia.org/wiki/Consistent_hashing
Наследование: implements Phan\Library\Hasher
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$_groupCount integer
$_hashRingGroups - Groups corresponding to hash values in _hashRingIds
$_hashRingIds - Sorted list of hash values, for binary search.

Открытые методы

Метод Описание
__construct ( integer $groupCount )
generate_key_hash ( string $material ) : integer Returns a 30-bit signed integer (i.e. in the range [0, self::MAX-1]) Designed to work on 32-bit php installations as well.
getGroup ( string $key ) : integer Do a binary search in the consistent hashing ring to find the group.
get_hashes_for_group ( integer $group ) : array
reset ( ) : void No-op reset

Описание методов

__construct() публичный Метод

public __construct ( integer $groupCount )
$groupCount integer

generate_key_hash() публичный статический Метод

Returns a 30-bit signed integer (i.e. in the range [0, self::MAX-1]) Designed to work on 32-bit php installations as well.
public static generate_key_hash ( string $material ) : integer
$material string
Результат integer

getGroup() публичный Метод

Do a binary search in the consistent hashing ring to find the group.
public getGroup ( string $key ) : integer
$key string
Результат integer - an integer between 0 and $this->_groupCount - 1, inclusive

get_hashes_for_group() публичный статический Метод

public static get_hashes_for_group ( integer $group ) : array
$group integer
Результат array

reset() публичный Метод

No-op reset
public reset ( ) : void
Результат void

Описание свойств

$_groupCount защищенное свойство

protected int $_groupCount
Результат integer

$_hashRingGroups защищенное свойство

- Groups corresponding to hash values in _hashRingIds
protected $_hashRingGroups

$_hashRingIds защищенное свойство

- Sorted list of hash values, for binary search.
protected $_hashRingIds