Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

MOVE

Last updated
MOVE key db
Group
Keys
Complexity
O(1)
Arity
3 (exactly, counting the command name)
Flags
write, fast
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

MOVE takes key out of the selected database and puts it in database db, with its time to live. Nothing happens when the key does not exist in the source or already exists in the target.

MOVE is not available on a cluster node with the default cluster-databases 1. With cluster-databases above 1, MOVE works between the node’s databases (the key keeps its slot). See Databases in a cluster.

Case RESP2 RESP3
Moved Integer 1 Integer 1
The key is missing, or the target already has a key with that name Integer 0 Integer 0

Errors:

  • ERR source and destination objects are the same when db is the selected database.
  • ERR DB index is out of range for a database that does not exist.
  • ERR MOVE is not allowed in cluster mode on a cluster node whose cluster-databases is 1.
127.0.0.1:6379> SET job:42 "pending"
OK
127.0.0.1:6379> MOVE job:42 1
(integer) 1
127.0.0.1:6379> EXISTS job:42
(integer) 0
127.0.0.1:6379> SELECT 1
OK
127.0.0.1:6379[1]> GET job:42
"pending"

Same as Redis 7 and Valkey 8.

COPY, RENAME, SELECT