YouTip LogoYouTip

Keys Renamenx

# Redis Renamenx Command [!(#) Redis Keys](#) The Redis RENAMENX command is used to rename a key if the new key does not exist. ### Syntax The basic syntax for the Redis RENAMENX command is as follows: redis 127.0.0.1:6379> RENAMENX OLD_KEY_NAME NEW_KEY_NAME ### Available Since >= 1.0.0 ### Return Value Returns 1 if the rename was successful. Returns 0 if the NEW_KEY_NAME already exists. ### Example # newkey does not exist, rename successful redis> SET player "MPlyaer" OK redis> EXISTS best_player (integer) 0 redis> RENAMENX player best_player (integer) 1 # newkey exists, rename fails 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" [!(#) Redis Keys](#)
← Event OnsearchEvent Onfocusin β†’