复制
Syntax
COPY source destination [DB destination-db] [REPLACE]
- Available since:
- 6.2.0
- Time complexity:
- O(N) worst case for collections, where N is the number of nested items. O(1) for string values.
- ACL categories:
-
@keyspace
,@write
,@slow
,
此命令将存储在source
键中的值复制到destination
键。
默认情况下,destination
键是在连接使用的逻辑数据库中创建的。DB
选项允许为目的地键指定一个替代的逻辑数据库索引。
当destination
键已经存在时,命令返回零。REPLACE
选项在将值复制到destination
键之前会删除该键。
示例
SET dolly "sheep"
COPY dolly clone
GET clone
RESP2/RESP3 回复
以下之一:
- Integer reply: 如果 source 被复制,则返回
1
。 - Integer reply: 如果source未被复制,则返回
0
。