mirror of
https://github.com/predis/predis.git
synced 2026-08-19 01:51:40 +00:00
Add the ability to get a connection out of a cluster using a key.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Predis\Network;
|
||||
|
||||
use Predis\Helpers;
|
||||
use Predis\ClientException;
|
||||
use Predis\Commands\ICommand;
|
||||
use Predis\Distribution\IDistributionStrategy;
|
||||
@@ -61,6 +62,12 @@ class ConnectionCluster implements IConnectionCluster, \IteratorAggregate {
|
||||
return isset($this->_pool[$alias]) ? $this->_pool[$alias] : null;
|
||||
}
|
||||
|
||||
public function getConnectionByKey($key) {
|
||||
$hashablePart = Helpers::getKeyHashablePart($key);
|
||||
$keyHash = $this->_distributor->generateKey($hashablePart);
|
||||
return $this->_distributor->get($keyHash);
|
||||
}
|
||||
|
||||
public function getIterator() {
|
||||
return new \ArrayIterator($this->_pool);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user