MOVE
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.
Return value
Section titled “Return value”| 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 samewhendbis the selected database.ERR DB index is out of rangefor a database that does not exist.ERR MOVE is not allowed in cluster modeon a cluster node whosecluster-databasesis 1.
Examples
Section titled “Examples”127.0.0.1:6379> SET job:42 "pending"OK127.0.0.1:6379> MOVE job:42 1(integer) 1127.0.0.1:6379> EXISTS job:42(integer) 0127.0.0.1:6379> SELECT 1OK127.0.0.1:6379[1]> GET job:42"pending"Compatibility
Section titled “Compatibility”Same as Redis 7 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.