Documentation

NaiveDistributor
in package
implements DistributorInterface, HashGeneratorInterface

Interfaces, Classes and Traits

DistributorInterface
A distributor implements the logic to automatically distribute keys among several nodes for client-side sharding.
HashGeneratorInterface
An hash generator implements the logic used to calculate the hash of a key to distribute operations among Redis nodes.

Table of Contents

$nodes  : mixed
$nodesCount  : mixed
__construct()  : mixed
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.
hash()  : int
Generates an hash from a string to be used for distribution.
remove()  : mixed
Removes a node from the distributor.

Properties

Methods

add()

Adds a node to the distributor with an optional weight.

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

Node object.

$weight : mixed = null

Weight for the node.

Return values
mixed

get()

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

public get(mixed $value) : mixed
Parameters
$value : mixed
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

hash()

Generates an hash from a string to be used for distribution.

public hash(mixed $value) : int
Parameters
$value : mixed

String value.

Return values
int

remove()

Removes a node from the distributor.

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

Node object.

Return values
mixed

Search results