Rename a key to a new key only if the new key does not exist
Renames key to newkey only if newkey does not yet exist. If key does not exist, an error is returned.
method
Rename a key to a new key only if the new key does not exist
Renames key to newkey only if newkey does not yet exist. If key does not exist, an error is returned.
The key to rename
The new key name
Promise that resolves with 1 if the key was renamed, 0 if newkey already exists
await redis.set("mykey", "Hello");
await redis.renamenx("mykey", "myotherkey"); // Returns 1
await redis.set("mykey2", "World");
await redis.renamenx("mykey2", "myotherkey"); // Returns 0 (myotherkey exists)