RENAME

Apply for Redis Developer Course Redis Regular Inspection / Technical Support Redis Enterprise Server

Rename a key

Usage: rename key new_key [type].
You can rename keys of all data types, not only strings.
If new_key already exists, it is deleted (DEL). If you do not want that, use RENAMENX.
type is one of string/list/set/zset/hash/stream.
      The type argument was added in ent811. Please use it.

Example

Command>mset key1 value1 key2 value2
Result>OK
Command>rename key1 key2 string
Result>OK
Command>get key2
Result>value1


Syntax

RENAME key new_key [type]

  • Available since version 1.0.0.
  • Time complexity is O(1).
  • The type argument was added in ent811.
Related commands RENAMENX
Clients for Java Jedis, Lettuce, Redisson
Clients for C Hiredis

<< SORT zset RENAME RENAMENX >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.