public function addPeer($label, CachePeer $peer, $mountPoint) { Assert::isLesserOrEqual($mountPoint, $this->summaryWeight); Assert::isGreaterOrEqual($mountPoint, 0); $this->doAddPeer($label, $peer); $this->peers[$label]['mountPoint'] = $mountPoint; $this->sorted = false; return $this; }
/** * brainless ;) **/ protected function guessLabel($key) { if ($this->peerAmount === null) { $this->peerAmount = count($this->peers); } if ($this->labels === null) { $this->labels = array_keys($this->peers); } Assert::isGreaterOrEqual($this->peerAmount, 1); return $this->labels[ord(substr($key, -1)) % $this->peerAmount]; }