Documentation

DistributorInterface

A distributor implements the logic to automatically distribute keys among several nodes for client-side sharding.

Tags
author

Daniele Alessandri suppakilla@gmail.com

Table of Contents

add()  : mixed
Adds a node to the distributor with an optional weight.
get()  : mixed
Returns a node from the distributor mapping to the specified value.
getByHash()  : mixed
Returns a node from the distributor using the computed hash of a key.
getBySlot()  : mixed|null
Returns a node from the distributor using its assigned slot ID.
getHashGenerator()  : HashGeneratorInterface
Returns the underlying hash generator instance.
getSlot()  : mixed
Returns the corresponding slot of a node from the distributor using the computed hash of a key.
remove()  : mixed
Removes a node from the distributor.

Methods

add()

Adds a node to the distributor with an optional weight.

public add(mixed $node[, int $weight = null ]) : mixed
Parameters
$node : mixed

Node object.

$weight : int = null

Weight for the node.

Return values
mixed

get()

Returns a node from the distributor mapping to the specified value.

public get(string $value) : mixed
Parameters
$value : string
Return values
mixed

getByHash()

Returns a node from the distributor using the computed hash of a key.

public getByHash(mixed $hash) : mixed
Parameters
$hash : mixed
Return values
mixed

getBySlot()

Returns a node from the distributor using its assigned slot ID.

public getBySlot(mixed $slot) : mixed|null
Parameters
$slot : mixed
Return values
mixed|null

getSlot()

Returns the corresponding slot of a node from the distributor using the computed hash of a key.

public getSlot(mixed $hash) : mixed
Parameters
$hash : mixed
Return values
mixed

remove()

Removes a node from the distributor.

public remove(mixed $node) : mixed
Parameters
$node : mixed

Node object.

Return values
mixed

Search results