Redis Renamenx 命令

Redis 教程 · 2019-03-06 21:11:28

Redis Renamenx 命令用于在新的 key 不存在时修改 key 的名称 。

语法

redis Renamenx 命令基本语法如下:

redis 127.0.0.1:6379> RENAMENX OLD_KEY_NAME NEW_KEY_NAME

可用版本

>= 1.0.0

返回值

修改成功时,返回 1 。 如果 NEW_KEY_NAME 已经存在,返回 0 。

实例

# 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"

点击查看所有 Redis 教程 文章: https://codercto.com/courses/l/33.html

查看所有标签

Head Rush Ajax

Head Rush Ajax

Brett McLaughlin、Eric Freeman、Elisabeth Freeman / O'Reilly Media, Inc. / 2006-03-01 / USD 34.99

Ajax, or Asynchronous JavaScript and XML, is a term describing the latest rage in web development. Ajax is used to create interactive web applications with XML-based web services, and using JavaScript......一起来看看 《Head Rush Ajax》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试