1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace Predis\Iterator;
- use Predis\Connection\SingleConnectionInterface;
- class MultiBulkResponseSimple extends MultiBulkResponse
- {
- private $connection;
-
- public function __construct(SingleConnectionInterface $connection, $size)
- {
- $this->connection = $connection;
- $this->position = 0;
- $this->current = $size > 0 ? $this->getValue() : null;
- $this->replySize = $size;
- }
-
- public function __destruct()
- {
- $this->sync(true);
- }
-
- public function sync($drop = false)
- {
- if ($drop == true) {
- if ($this->valid()) {
- $this->position = $this->replySize;
- $this->connection->disconnect();
- }
- } else {
- while ($this->valid()) {
- $this->next();
- }
- }
- }
-
- protected function getValue()
- {
- return $this->connection->read();
- }
-
- public function asTuple()
- {
- return new MultiBulkResponseTuple($this);
- }
- }
|