mirror of
https://github.com/predis/predis.git
synced 2026-09-10 18:37:34 +00:00
Minor code styling adjustments.
This commit is contained in:
@@ -53,7 +53,11 @@ class HashRing implements DistributorInterface, HashGeneratorInterface
|
||||
{
|
||||
// In case of collisions in the hashes of the nodes, the node added
|
||||
// last wins, thus the order in which nodes are added is significant.
|
||||
$this->nodes[] = array('object' => $node, 'weight' => (int) $weight ?: $this::DEFAULT_WEIGHT);
|
||||
$this->nodes[] = array(
|
||||
'object' => $node,
|
||||
'weight' => (int) $weight ?: $this::DEFAULT_WEIGHT
|
||||
);
|
||||
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
@@ -70,6 +74,7 @@ class HashRing implements DistributorInterface, HashGeneratorInterface
|
||||
if ($this->nodes[$i]['object'] === $node) {
|
||||
array_splice($this->nodes, $i, 1);
|
||||
$this->reset();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -166,7 +171,7 @@ class HashRing implements DistributorInterface, HashGeneratorInterface
|
||||
*/
|
||||
protected function getNodeHash($nodeObject)
|
||||
{
|
||||
if ($this->nodeHashCallback === null) {
|
||||
if (!isset($this->nodeHashCallback)) {
|
||||
return (string) $nodeObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ class KetamaRing extends HashRing
|
||||
public function hash($value)
|
||||
{
|
||||
$hash = unpack('V', md5($value, true));
|
||||
|
||||
return $hash[1];
|
||||
}
|
||||
|
||||
@@ -63,7 +64,7 @@ class KetamaRing extends HashRing
|
||||
*/
|
||||
protected function wrapAroundStrategy($upper, $lower, $ringKeysCount)
|
||||
{
|
||||
// Binary search for the first item in _ringkeys with a value greater
|
||||
// Binary search for the first item in ringkeys with a value greater
|
||||
// or equal to the key. If no such item exists, return the first item.
|
||||
return $lower < $ringKeysCount ? $lower : 0;
|
||||
}
|
||||
|
||||
@@ -192,7 +192,9 @@ class PredisStrategy implements StrategyInterface
|
||||
}
|
||||
|
||||
if (!is_callable($callback)) {
|
||||
throw new \InvalidArgumentException("Callback must be a valid callable object or NULL");
|
||||
throw new \InvalidArgumentException(
|
||||
"Callback must be a valid callable object or NULL"
|
||||
);
|
||||
}
|
||||
|
||||
$this->commands[$commandID] = $callback;
|
||||
|
||||
Reference in New Issue
Block a user