Keyspace.php 1021 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 by leveraging the
  14. * SCAN command (Redis >= 2.8) wrapped in a fully-rewindable PHP iterator.
  15. *
  16. * @author Daniele Alessandri <suppakilla@gmail.com>
  17. * @link http://redis.io/commands/scan
  18. */
  19. class Keyspace extends CursorBasedIterator
  20. {
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function __construct(ClientInterface $client, $match = null, $count = null)
  25. {
  26. $this->requiredCommand($client, 'SCAN');
  27. parent::__construct($client, $match, $count);
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. protected function executeCommand()
  33. {
  34. return $this->client->scan($this->cursor, $this->getScanOptions());
  35. }
  36. }