PHP Class Predis\Cluster\Distributor\HashRing

Author: Daniele Alessandri ([email protected])
Author: Lorenzo Castelli ([email protected])
Inheritance: implements Predis\Cluster\Distributor\DistributorInterface, implements Predis\Cluster\Hash\HashGeneratorInterface
Datei anzeigen Open project: tillkruss/redis-object-cache Class Usage Examples

Public Methods

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 )

Protected Methods

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.

Private Methods

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.

Method Details

__construct() public method

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() public method

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() protected method

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 method

public get ( $value )

getByHash() public method

public getByHash ( $hash )

getBySlot() public method

public getBySlot ( $slot )

getHashGenerator() public method

public getHashGenerator ( )

getNodeHash() protected method

protected getNodeHash ( $nodeObject )

getSlot() public method

public getSlot ( $hash )

hash() public method

public hash ( $value )

remove() public method

public remove ( $node )

wrapAroundStrategy() protected method

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
return integer