Duplicating a key used to mean serialising it out and back in, which moved the whole value through the client for no reason.
# before
DUMP mykey # bytes to the client
RESTORE mycopy 0 ... # and back again
# 6.2
COPY mykey mycopy
COPY mykey mycopy REPLACE
COPY mykey mycopy DB 3
# returns 0 if the destination exists and REPLACE
# was not given — so it is safe by default.
Staying server-side matters for a large hash or sorted set, where the round trip is the whole cost. The DB option makes it a cross-database copy within one instance, which is occasionally useful for promoting a rebuilt index — build into database 3, verify, then copy across. Returning 0 rather than overwriting is the right default and means a script has to check the return value rather than assume.