title: How to use SCAN with the MATCH option in Predis
body: <p>I have previously used the <a href="http://redis.io/commands/keys"><code>KEYS</code></a> command to search for keys matching a certain pattern in my Redis database. Since Redis 2.8, the <a href="http://redis.io/commands/scan"><code>SCAN</code></a> command seems to be preferred over <code>KEYS</code> since it returns an iterator instead of scanning through the whole keyspace at once.</p>
  
  <p>I'm using <a href="https://github.com/nrk/predis">Predis</a> >= 0.8.5 which is supposed to support PHP iterators for the <code>SCAN</code> command. Predis doesn't have a lot of documentation, so I'm wondering how to translate the following <code>KEYS</code> command to it's <code>SCAN</code> counterpart:</p>
  
  <pre><code>$client-&gt;keys($pattern)
  </code></pre>
  
  <p>I have tried the following:</p>
  
  <pre><code>$client-&gt;scan('MATCH', $pattern);
  </code></pre>
  
  <p>Which kind of works - but it doesn't return a native PHP iterator. It would be really nice to use Predis' built-in iterator support.</p>