Mrename
Bun

method

RedisClient.rename

key: KeyLike,
newkey: KeyLike
): Promise<'OK'>;

Rename a key to a new key

Renames key to newkey. If newkey already exists, it is overwritten. If key does not exist, an error is returned.

@param key

The key to rename

@param newkey

The new key name

@returns

Promise that resolves with "OK" on success

await redis.set("mykey", "Hello");
await redis.rename("mykey", "myotherkey");
const value = await redis.get("myotherkey"); // "Hello"
const oldValue = await redis.get("mykey"); // null

Referenced types

type KeyLike = string | ArrayBufferView | Blob