More trivial changes for HashRing::add and HashRing::remove.

This commit is contained in:
Daniele Alessandri
2009-12-18 21:08:42 +01:00
parent d3115e6259
commit f811877c87
+4 -2
View File
@@ -832,7 +832,8 @@ class HashRing {
public function add($node) {
$nodeHash = (string) $node;
for ($i = 0; $i < $this->_replicas; $i++) {
$replicas = $this->_replicas;
for ($i = 0; $i < $replicas; $i++) {
$key = crc32($nodeHash . ':' . $i);
$this->_ring[$key] = $node;
}
@@ -842,7 +843,8 @@ class HashRing {
public function remove($node) {
$nodeHash = (string) $node;
for ($i = 0; $i < $this->_replicas; $i++) {
$replicas = $this->_replicas;
for ($i = 0; $i < $replicas; $i++) {
$key = crc32($nodeHash . ':' . $i);
unset($this->_ring[$key]);
$this->_ringKeys = array_filter($this->_ringKeys, function($rk) use($key) {