This article mainly introduces the method of using PHP to export Redis data to another redis, you need friends can refer to the following
Export data from one Redis db to another Redis db PHP script: Code as follows: $from = ' 127.0.0.1:6200/6 '; $to = ' 127.0.0.1:6200/8 '; $from _redis = Redis_init ($from); $to _redis = Redis_init ($to); $keys = $from _redis->keys (' * '); $count = 0; $total = count ($keys); foreach ($keys as $key) { if (+ + $count% = 1) { echo "$count/$totaln"; & nbsp } $type = $from _redis->type ($key); Switch ($type) { redis::redis_string: &NBS P $val = $from _redis->get ($key); $to _redis->set ($key, $val); break; case redis::redis_list: $list = $from _redis->lran GE ($key, 0,-1); foreach ($list as $val) { $to _reDis->rpush ($key, $val); break; case Redis::redis_hash: $hash = $from _redis->hget All ($key); $to _redis->hmset ($key, $hash); break; case Redis::redis_zset: $zset = $from _redis->zran GE ($key, 0,-1, true); foreach ($zset as $val => $score) { &NB Sp $to _redis->zadd ($key, $score, $val); break; } function Redis_init ($conf) { $redis = new Redis (); Preg_match ('/^ [^:] +) (: [0-9]+)?/(. +)?/', $conf, $ms); $host = $ms [1]; $port = trIm ($ms [2], ': '); $DB = $ms [3]; $redis->connect ($host, $port); $redis->select ($DB); return $redis; }