mirror of
https://github.com/predis/predis.git
synced 2026-09-13 20:07:28 +00:00
MultiBulkResponseIterator now implements the Countable interface.
This commit is contained in:
+8
-1
@@ -1129,7 +1129,7 @@ class HashRing {
|
||||
}
|
||||
}
|
||||
|
||||
class MultiBulkResponseIterator implements \Iterator {
|
||||
class MultiBulkResponseIterator implements \Iterator, \Countable {
|
||||
private $_connection, $_position, $_current, $_replySize;
|
||||
|
||||
public function __construct($socket, $size) {
|
||||
@@ -1176,6 +1176,13 @@ class MultiBulkResponseIterator implements \Iterator {
|
||||
return $this->_position < $this->_replySize;
|
||||
}
|
||||
|
||||
public function count() {
|
||||
// NOTE: use count if you want to get the size of the current multi-bulk
|
||||
// response without using iterator_count (which actually consumes
|
||||
// our iterator to calculate the size, and we cannot perform a rewind)
|
||||
return $this->_replySize;
|
||||
}
|
||||
|
||||
private function getValue() {
|
||||
return \Predis\Response::read($this->_connection);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user