Generic
RENAME
Rename a key
Renames a key and overwrites the new key if it already exists.
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.rename("key1", "key2")assert redis.get("key1") is Noneassert redis.get("key2") == "Hello"# Renaming a nonexistent key throws an exceptionredis.rename("nonexistent", "key3")