PHP Класс Flexihash\Flexihash

Показать файл Открыть проект Примеры использования класса

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

Метод Описание
__construct ( Flexihash\Hasher\HasherInterface $hasher = null, integer $replicas = null ) Constructor.
__toString ( )
addTarget ( string $target, float $weight = 1 ) Add a target.
addTargets ( array $targets, float $weight = 1 ) : self Add a list of targets.
getAllTargets ( ) : array A list of all potential targets.
lookup ( string $resource ) : string Looks up the target for the given resource.
lookupList ( string $resource, integer $requestedCount ) : array Get a list of targets for the resource, in order of precedence.
removeTarget ( string $target ) : self Remove a target.

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

Метод Описание
sortPositionTargets ( ) Sorts the internal mapping (positions to targets) by position.

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

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

Constructor.
public __construct ( Flexihash\Hasher\HasherInterface $hasher = null, integer $replicas = null )
$hasher Flexihash\Hasher\HasherInterface
$replicas integer Amount of positions to hash each target to.

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

public __toString ( )

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

Add a target.
public addTarget ( string $target, float $weight = 1 )
$target string
$weight float

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

Add a list of targets.
public addTargets ( array $targets, float $weight = 1 ) : self
$targets array
$weight float
Результат self fluent

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

A list of all potential targets.
public getAllTargets ( ) : array
Результат array

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

Looks up the target for the given resource.
public lookup ( string $resource ) : string
$resource string
Результат string

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

Up to $requestedCount targets are returned, less if there are fewer in total.
public lookupList ( string $resource, integer $requestedCount ) : array
$resource string
$requestedCount integer The length of the list to return
Результат array List of targets

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

Remove a target.
public removeTarget ( string $target ) : self
$target string
Результат self fluent