Copy 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 REPLACE option removes the destination key before copying the value to it.
method
Copy 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 REPLACE option removes the destination key before copying the value to it.
The source key to copy from
The destination key to copy to
Promise that resolves with 1 if the key was copied, 0 if not
await redis.set("mykey", "Hello");
await redis.copy("mykey", "myotherkey");
console.log(await redis.get("myotherkey")); // "Hello"
Copy the value stored at the source key to the destination key, optionally replacing it
The REPLACE option removes the destination key before copying the value to it.
The source key to copy from
The destination key to copy to
"REPLACE" - Remove the destination key before copying
Promise that resolves with 1 if the key was copied, 0 if not
await redis.set("mykey", "Hello");
await redis.set("myotherkey", "World");
await redis.copy("mykey", "myotherkey", "REPLACE");
console.log(await redis.get("myotherkey")); // "Hello"