mirror of
https://github.com/predis/predis.git
synced 2026-08-30 12:15:03 +00:00
Rename RedisCluster::askClusterNodes() to askSlotsMap().
This is more consistent with the actual purpose of this method and more in-line with a possible future change in the underlying command used to retrieve the slots map if redis-cluster will implement the CLUSTER SLOTS command.
This commit is contained in:
@@ -48,7 +48,7 @@ use Predis\Response\ErrorInterface as ErrorResponseInterface;
|
||||
*/
|
||||
class RedisCluster implements ClusterInterface, IteratorAggregate, Countable
|
||||
{
|
||||
private $askClusterNodes = false;
|
||||
private $askSlotsMap = false;
|
||||
private $defaultParameters = array();
|
||||
private $pool = array();
|
||||
private $slots = array();
|
||||
@@ -173,8 +173,10 @@ class RedisCluster implements ClusterInterface, IteratorAggregate, Countable
|
||||
/**
|
||||
* Generates the current slots map by fetching the cluster configuration to
|
||||
* one of the nodes by leveraging the CLUSTER NODES command.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function askClusterNodes()
|
||||
public function askSlotsMap()
|
||||
{
|
||||
if (!$connection = $this->getRandomConnection()) {
|
||||
return array();
|
||||
@@ -201,6 +203,8 @@ class RedisCluster implements ClusterInterface, IteratorAggregate, Countable
|
||||
$this->setSlots($slots[0], $slots[1], $node[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->slotsMap;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -406,8 +410,8 @@ class RedisCluster implements ClusterInterface, IteratorAggregate, Countable
|
||||
$connection = $this->createConnection($connectionID);
|
||||
}
|
||||
|
||||
if ($this->askClusterNodes) {
|
||||
$this->askClusterNodes();
|
||||
if ($this->askSlotsMap) {
|
||||
$this->askSlotsMap();
|
||||
}
|
||||
|
||||
$this->move($connection, $slot);
|
||||
@@ -504,14 +508,14 @@ class RedisCluster implements ClusterInterface, IteratorAggregate, Countable
|
||||
* procedure, mostly when targeting many keys that would end up in a lot of
|
||||
* redirections.
|
||||
*
|
||||
* The slots map can still be manually fetched using the askClusterNodes()
|
||||
* The slots map can still be manually fetched using the askSlotsMap()
|
||||
* method whether or not this option is enabled.
|
||||
*
|
||||
* @param bool $value Enable or disable the use of CLUSTER NODES.
|
||||
*/
|
||||
public function enableClusterNodes($value)
|
||||
public function enableAutoSlotsMap($value)
|
||||
{
|
||||
$this->askClusterNodes = (bool) $value;
|
||||
$this->askSlotsMap = (bool) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -655,7 +655,7 @@ EOS;
|
||||
$cluster = new RedisCluster($factory);
|
||||
$cluster->add($connection1);
|
||||
|
||||
$cluster->askClusterNodes();
|
||||
$cluster->askSlotsMap();
|
||||
|
||||
$this->assertSame($cluster->getConnectionBySlot('6144'), $connection1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user