Redis Commands
- A
- B
- Client
-
Cluster
- Cluster-addslots
- Cluster-addslotsrange
- Cluster-bumpepoch
- Cluster-count-failure-reports
- Cluster-countkeysinslot
- Cluster-delslots
- Cluster-delslotsrange
- Cluster-failover
- Cluster-flushslots
- Cluster-forget
- Cluster-getkeysinslot
- Cluster-help
- Cluster-info
- Cluster-keyslot
- Cluster-links
- Cluster-meet
- Cluster-myid
- Cluster-myshardid
- Cluster-nodes
- Cluster-replicas
- Cluster-replicate
- Cluster-reset
- Cluster-saveconfig
- Cluster-set-config-epoch
- Cluster-setslot
- Cluster-shards
- Cluster-slaves
- Cluster-slots
- Cluster
- Command
- Config
- D
- E
- F
- G
- H
- I
- K
- L
- M
- O
- P
- Q
- R
- S1
- S2
- T
- U
- W
- X
- Z1
- Z2
Docs > Redis Commands > R > Renamenx
Renames key
to newkey
if newkey
does not yet exist.
It returns an error when key
does not exist.
In Cluster mode, both key
and newkey
must be in the same hash slot, meaning that in practice only keys that have the same hash tag can be reliably renamed in cluster.
@return
@integer-reply, specifically:
1
ifkey
was renamed tonewkey
.0
ifnewkey
already exists.
@examples
SET mykey "Hello"
SET myotherkey "World"
RENAMENX mykey myotherkey
GET myotherkey