Redis comando Cambiar nombre
Redis comando Cambiar nombre se utiliza para modificar los nombres de las teclas.
gramática
Redis comando Cambiar nombre sintaxis básica es la siguiente:
redis 127.0.0.1:6379> RENAME OLD_KEY_NAME NEW_KEY_NAME
versiones disponibles
> = 1.0.0
Valor de retorno
Al cambiar el nombre éxito impulsó OK, fallar cuando se devuelve un error.
Cuando OLD_KEY_NAME misma NEW_KEY_NAME, o OLD_KEY_NAME no existe, se devuelve un error. Cuando NEW_KEY_NAME ya existe, cambie el nombre de comando sobrescribe el valor anterior.
Ejemplos
# key 存在且 newkey 不存在 redis> SET message "hello world" OK redis> RENAME message greeting OK redis> EXISTS message # message 不复存在 (integer) 0 redis> EXISTS greeting # greeting 取而代之 (integer) 1 # 当 key 不存在时,返回错误 redis> RENAME fake_key never_exists (error) ERR no such key # newkey 已存在时, RENAME 会覆盖旧 newkey redis> SET pc "lenovo" OK redis> SET personal_computer "dell" OK redis> RENAME pc personal_computer OK redis> GET pc (nil) redis:1> GET personal_computer # 原来的值 dell 被覆盖了 "lenovo"