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.

RENAME

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

RENAME moves the value at key to newkey. If newkey already exists, its value is replaced. The value keeps its time to live. Renaming a key to its own name succeeds and changes nothing.

In a cluster, key and newkey must hash to the same slot.

Case RESP2 RESP3
Renamed Simple string OK Simple string OK
key does not exist Error ERR no such key Error
127.0.0.1:6379> SET draft "v1"
OK
127.0.0.1:6379> RENAME draft published
OK
127.0.0.1:6379> GET published
"v1"
127.0.0.1:6379> RENAME draft other
(error) ERR no such key

Same as Redis 7 and Valkey 8.

RENAMENX, COPY, MOVE