method
RedisClient.copy
copy(
): Promise<number>;
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.
@param source
The source key to copy from
@param destination
The destination key to copy to
@returns
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(
replace: 'REPLACE'
): Promise<number>;
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.
@param source
The source key to copy from
@param destination
The destination key to copy to
@param replace
"REPLACE" - Remove the destination key before copying
@returns
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"Referenced types
type KeyLike = string | ArrayBufferView | Blob