Copying all keys in Redis database using MIGRATE

前端 未结 5 2291
Happy的楠姐
Happy的楠姐 2021-02-20 08:13

Is it possible to copy all keys from one Redis instance to another remote instance using MIGRATE? I\'ve tried COPY, REPLACE and KEYS

5条回答
  •  醉梦人生
    2021-02-20 08:50

    I'm not advocating using this, but I tried all of these examples, and many others and did not work. I ended up doing it myself in PHP, so maybe this will help someone else who is stuck.

    connect('1.2.3.4', 6379);
    $redisSource->auth('password');
    
    $redisTarget = new Redis();
    $redisTarget->connect('127.0.0.1', 6379);
    
    foreach($redisSource->keys('*') as $key) {
        $redisTarget->set($key, $redisSource->get($key));
    }
    

提交回复
热议问题