Predis\Cluster\Distributor\HashRing::getSlot PHP Метод

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

public getSlot ( $hash )
    public function getSlot($hash)
    {
        $this->initialize();
        $ringKeys = $this->ringKeys;
        $upper = $this->ringKeysCount - 1;
        $lower = 0;
        while ($lower <= $upper) {
            $index = $lower + $upper >> 1;
            $item = $ringKeys[$index];
            if ($item > $hash) {
                $upper = $index - 1;
            } elseif ($item < $hash) {
                $lower = $index + 1;
            } else {
                return $item;
            }
        }
        return $ringKeys[$this->wrapAroundStrategy($upper, $lower, $this->ringKeysCount)];
    }