/** * function that takes all keys from source redis, dumps them and imports to the new redis */ public function copy() { // retrieve all keys from source redis $keys = $this->source->keys('*'); $this->out("Processing %d REDIS keys ...", count($keys), true); $hundred = 0; $step = 0; foreach ($keys as $key) { // check for ignored keys and skip the key if it should be ignored foreach ($this->ignoredPrefixes as $ignoredPrefix) { if (strpos($key, $ignoredPrefix) !== false) { $this->out('.'); continue 2; // continue with the next key } } try { $ttl = max(0, (int) $this->source->ttl($key)); $serializedValue = $this->source->dump($key); $this->destination->restore($key, $ttl, $serializedValue); } catch (Exception $e) { $this->out(PHP_EOL . 'ERROR: ' . $key . PHP_EOL); } if ($step++ % 100 == 0) { $this->out(PHP_EOL . $hundred++ . ': '); } $this->out('o'); } $this->out(PHP_EOL . PHP_EOL); }