mirror of
https://github.com/predis/predis.git
synced 2026-08-30 12:15:03 +00:00
ConnectionCluster now implements the IteratorAggregate interface, thus enabling iterations over the registered connections simply by using a foreach loop.
This commit is contained in:
+5
-1
@@ -717,7 +717,7 @@ class Connection implements IConnection {
|
||||
}
|
||||
}
|
||||
|
||||
class ConnectionCluster implements IConnection {
|
||||
class ConnectionCluster implements IConnection, \IteratorAggregate {
|
||||
// TODO: storing a temporary map of commands hashes to hashring items (that
|
||||
// is, connections) could offer a notable speedup, but I am wondering
|
||||
// about the increased memory footprint.
|
||||
@@ -778,6 +778,10 @@ class ConnectionCluster implements IConnection {
|
||||
return $this->_pool[$id === null ? 0 : $id];
|
||||
}
|
||||
|
||||
public function getIterator() {
|
||||
return new \ArrayIterator($this->_pool);
|
||||
}
|
||||
|
||||
public function writeCommand(Command $command) {
|
||||
$this->getConnection($command)->writeCommand($command);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user