Arguments
str
required
The original key.
str
required
A new name for the key.
Response
True if key was renamedDocumentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
redis.set("key1", "Hello")
redis.rename("key1", "key2")
assert redis.get("key1") is None
assert redis.get("key2") == "Hello"
# Renaming a nonexistent key throws an exception
redis.rename("nonexistent", "key3")
Rename a key
True if key was renamedredis.set("key1", "Hello")
redis.rename("key1", "key2")
assert redis.get("key1") is None
assert redis.get("key2") == "Hello"
# Renaming a nonexistent key throws an exception
redis.rename("nonexistent", "key3")
Was this page helpful?