PHP 클래스 Phan\Library\Hasher\Consistent

See https://en.wikipedia.org/wiki/Consistent_hashing
상속: implements Phan\Library\Hasher
파일 보기 프로젝트 열기: etsy/phan

보호된 프로퍼티들

프로퍼티 타입 설명
$_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