Method | Description | |
---|---|---|
__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 ) |
Method | Description | |
---|---|---|
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. |
Method | Description | |
---|---|---|
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. |
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. |
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. |