redis RENAMENX command


  Translation results:

rename

UK[ˌri:ˈneɪm] US[ˌriːˈneɪm]

vt. Rename..., change the name

Third person singular : renames present participle: renaming past tense: renamed past participle: renamed

redis RENAMENX commandsyntax

Function: If and only if newkey does not exist, rename key to newkey. When key does not exist, an error is returned.

Syntax: RENAMENX key newkey

Available versions:>= 1.0.0

Time complexity : O(1)

Return: When the modification is successful, return 1. If newkey already exists, return 0.

redis RENAMENX commandexample

# newkey 不存在,改名成功
redis> SET player "MPlyaer"
OK
redis> EXISTS best_player
(integer) 0
redis> RENAMENX player best_player
(integer) 1
# newkey存在时,失败
redis> SET animal "bear"
OK
redis> SET favorite_animal "butterfly"
OK
redis> RENAMENX animal favorite_animal
(integer) 0
redis> get animal
"bear"
redis> get favorite_animal
"butterfly"

Home

Videos

Q&A