MIGRATE

Since 1.1.0Cluster

Syntax

MIGRATE host port key|"" db timeout [COPY] [REPLACE] [AUTH password | AUTH2 username password] [KEYS key [key ...]]
  • Flags: movablekeys, readonly
  • ACL categories: @dangerous, @generic, @keyspace, @read, @slow
  • Arity: -6

Moves keys to another server: each is serialised, restored on the server at host port in database db, with its time to live, and deleted here once the other server has acknowledged it. One key is given as key; several are given after KEYS, with "" in place of key. timeout is in milliseconds.

OptionEffect
COPYKeep the keys here.
REPLACEOverwrite keys that exist on the other server.
AUTH passwordLog in to the other server.
AUTH2 username passwordLog in to the other server as username.

In a cluster, this is the third step of moving a slot by hand: see CLUSTER SETSLOT.

Reply

  • OK.
  • NOKEY when none of the keys exist.
  • ERR Target instance replied with error: BUSYKEY Target key name already exists., without REPLACE.

Examples

> MIGRATE 127.0.0.1 17622 user:7 0 5000
OK
> MIGRATE 127.0.0.1 17622 "" 0 5000 KEYS m1 m2
OK