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 command returns zero when the destination key already exists. The REPLACE option removes the destination key before copying the value to it.

Reply

One of the following:

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

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)

Info

2024-09-23 8.0.0 Valkey Command Manual