Select all key data for a specific pattern from Redis using PHP
<p>I am using <a href="https://github.com/phpredis/phpredis" rel="nofollow">PHPRedis</a> for this.</p>

<p>I need to create script that copies all of the keys with the pattern <code>mobile*</code> from one Redis <strong>host1</strong> to <strong>host2</strong>. </p>

<p>I have got this working by selecting all keys from <strong>host1</strong> with the pattern <code>mobile*</code>. Then looping over each of these keys using the <code>get</code> key method to return the data. I then set the key for <strong>host2</strong> using the <code>set</code> method:</p>

<pre><code>$auKeys = $redis-&gt;keys("mobile*");
foreach ($auKeys as $key) {
    $data = $redis-&gt;get($key);
    $redis2-&gt;set($key, $data, 6000);
    echo $key;
}
</code></pre>

<p>The problem is this takes around 5 minutes - I need to get it down to 2-3 minutes. Is there another way to do this?</p>