copy.3valkey - Man Page
Copies the value of a key to a new key.
Synopsis
COPY source destination [DB destination-db] [REPLACE]
Description
This command copies the value stored at the source key to the destination key.
By default, the destination key is created in the logical database used by the connection. The DB option allows specifying an alternative logical database index for the destination key. The REPLACE option removes the destination key before copying the value to it.
The command returns zero when the source key does not exist or when the destination key already exists and the REPLACE option is not specified.
When the DB option is used, the caller must have ACL permission to access the specified destination database. See valkey-acl(7) database permissions.
Reply
One of the following:
- valkey-protocol(7) Integer reply:
1if source was copied. - valkey-protocol(7) Integer reply:
0if source was not copied when the destination key already exists.
Complexity
O(N) worst case for collections, where N is the number of nested items. O(1) for string values.
Acl Categories
@keyspace @slow @write
History
- Available since: 6.2.0
Examples
SET dolly "sheep" COPY dolly clone GET clone
See Also
del(3valkey), dump(3valkey), exists(3valkey), expire(3valkey), expireat(3valkey), expiretime(3valkey), keys(3valkey), migrate(3valkey), move(3valkey), object(3valkey), object-encoding(3valkey), object-freq(3valkey), object-help(3valkey), object-idletime(3valkey), object-refcount(3valkey), persist(3valkey), pexpire(3valkey), pexpireat(3valkey), pexpiretime(3valkey), pttl(3valkey), randomkey(3valkey), rename(3valkey), renamenx(3valkey), restore(3valkey), scan(3valkey), sort(3valkey), sort_ro(3valkey), touch(3valkey), ttl(3valkey), type(3valkey), unlink(3valkey), wait(3valkey), waitaof(3valkey)