SetKey.php 1.1 KB

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