SetKey.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 members stored in a set by leveraging the SSCAN
  14. * 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 SetKey extends CursorBasedIterator
  20. {
  21. protected $key;
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function __construct(ClientInterface $client, $key, $match = null, $count = null)
  26. {
  27. $this->requiredCommand($client, 'SSCAN');
  28. parent::__construct($client, $match, $count);
  29. $this->key = $key;
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. protected function executeCommand()
  35. {
  36. return $this->client->sscan($this->key, $this->cursor, $this->getScanOptions());
  37. }
  38. }