PHP Класс Predis\Cluster\Distributor\HashRing

Автор: Daniele Alessandri ([email protected])
Автор: Lorenzo Castelli ([email protected])
Наследование: implements Predis\Cluster\Distributor\DistributorInterface, implements Predis\Cluster\Hash\HashGeneratorInterface
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
__construct ( integer $replicas = self::DEFAULT_REPLICAS, mixed $nodeHashCallback = null )
add ( mixed $node, integer $weight = null ) Adds a node to the ring with an optional weight.
get ( $value )
getByHash ( $hash )
getBySlot ( $slot )
getHashGenerator ( )
getSlot ( $hash )
hash ( $value )
remove ( $node )

Защищенные методы

Метод Описание
addNodeToRing ( array &$ring, mixed $node, integer $totalNodes, integer $replicas, float $weightRatio ) Implements the logic needed to add a node to the hashring.
getNodeHash ( $nodeObject )
wrapAroundStrategy ( integer $upper, integer $lower, integer $ringKeysCount ) : integer Implements a strategy to deal with wrap-around errors during binary searches.

Приватные методы

Метод Описание
computeTotalWeight ( ) : integer Calculates the total weight of all the nodes in the distributor.
initialize ( ) Initializes the distributor.
isInitialized ( ) : boolean Returns the initialization status of the distributor.
reset ( ) Resets the distributor.

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

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

public __construct ( integer $replicas = self::DEFAULT_REPLICAS, mixed $nodeHashCallback = null )
$replicas integer Number of replicas in the ring.
$nodeHashCallback mixed Callback returning a string used to calculate the hash of nodes.

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

Adds a node to the ring with an optional weight.
public add ( mixed $node, integer $weight = null )
$node mixed Node object.
$weight integer Weight for the node.

addNodeToRing() защищенный Метод

Implements the logic needed to add a node to the hashring.
protected addNodeToRing ( array &$ring, mixed $node, integer $totalNodes, integer $replicas, float $weightRatio )
$ring array Source hashring.
$node mixed Node object to be added.
$totalNodes integer Total number of nodes.
$replicas integer Number of replicas in the ring.
$weightRatio float Weight ratio for the node.

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

public get ( $value )

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

public getByHash ( $hash )

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

public getBySlot ( $slot )

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

public getHashGenerator ( )

getNodeHash() защищенный Метод

protected getNodeHash ( $nodeObject )

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

public getSlot ( $hash )

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

public hash ( $value )

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

public remove ( $node )

wrapAroundStrategy() защищенный Метод

Implements a strategy to deal with wrap-around errors during binary searches.
protected wrapAroundStrategy ( integer $upper, integer $lower, integer $ringKeysCount ) : integer
$upper integer
$lower integer
$ringKeysCount integer
Результат integer