@@ -561,7 +561,7 @@ class Redis:
561
561
"""
562
562
RESPONSE_CALLBACKS = {
563
563
** string_keys_to_dict (
564
- 'AUTH EXPIRE EXPIREAT HEXISTS HMSET MOVE MSETNX PERSIST '
564
+ 'AUTH COPY EXPIRE EXPIREAT HEXISTS HMSET MOVE MSETNX PERSIST '
565
565
'PSETEX RENAMENX SISMEMBER SMOVE SETEX SETNX' ,
566
566
bool
567
567
),
@@ -1612,6 +1612,24 @@ def bitpos(self, key, bit, start=None, end=None):
1612
1612
"when end is specified" )
1613
1613
return self .execute_command ('BITPOS' , * params )
1614
1614
1615
+ def copy (self , source , destination , destination_db = None , replace = False ):
1616
+ """
1617
+ Copy the value stored in the ``source`` key to the ``destination`` key.
1618
+
1619
+ ``destination_db`` an alternative destination database. By default,
1620
+ the ``destination`` key is created in the source Redis database.
1621
+
1622
+ ``replace`` whether the ``destination`` key should be removed before
1623
+ copying the value to it. By default, the value is not copied if
1624
+ the ``destination`` key already exists.
1625
+ """
1626
+ params = [source , destination ]
1627
+ if destination_db is not None :
1628
+ params .extend (["DB" , destination_db ])
1629
+ if replace :
1630
+ params .append ("REPLACE" )
1631
+ return self .execute_command ('COPY' , * params )
1632
+
1615
1633
def decr (self , name , amount = 1 ):
1616
1634
"""
1617
1635
Decrements the value of ``key`` by ``amount``. If no key exists,
0 commit comments