Keyspace.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /*
  3. * This file is part of the Predis package.
  4. *
  5. * (c) Daniele Alessandri <suppakilla@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Predis\Collection\Iterator;
  11. use Predis\ClientInterface;
  12. /**
  13. * Abstracts the iteration of the keyspace on a Redis instance
  14. * by leveraging the SCAN command (Redis >= 2.8) wrapped in a
  15. * fully-rewindable PHP iterator.
  16. *
  17. * @author Daniele Alessandri <suppakilla@gmail.com>
  18. * @link http://redis.io/commands/scan
  19. */
  20. class Keyspace extends CursorBasedIterator
  21. {
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function __construct(ClientInterface $client, $match = null, $count = null)
  26. {
  27. $this->requiredCommand($client, 'SCAN');
  28. parent::__construct($client, $match, $count);
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. protected function executeCommand()
  34. {
  35. return $this->client->scan($this->cursor, $this->getScanOptions());
  36. }
  37. }