Generic
RENAMENX
Rename a key if it does not already exist.
Renames a key, only if the new key does not exist.
Throws an exception if the key does not exist.
Arguments
sourcebodystrrequired
The original key.
destinationbodystrrequired
A new name for the key.
Response
boolrequired
True if key was renamed
Example
redis.set("key1", "Hello")redis.set("key2", "World")# Rename failed because "key2" already exists.assert redis.renamenx("key1", "key2") == Falseassert redis.renamenx("key1", "key3") == Trueassert redis.get("key1") is Noneassert redis.get("key2") == "World"assert redis.get("key3") == "Hello"