Redis Hsetnx 命令

更新时间: 2019-07-07 15:54

Redis Hsetnx 命令用于为哈希表中不存在的的字段赋值 。

如果哈希表不存在,一个新的哈希表被创建并进行 HSET 操作。

如果字段已经存在于哈希表中,操作无效。

如果 key 不存在,一个新哈希表被创建并执行 HSETNX 命令。

语法

redis 127.0.0.1:6379> HSETNX KEY_NAME FIELD VALUE

返回值

设置成功,返回 1 。 如果给定字段已经存在且没有操作被执行,返回 0 。

实例

redis 127.0.0.1:6379> HSETNX myhash field1 "foo"
(integer) 1
redis 127.0.0.1:6379> HSETNX myhash field1 "bar"
(integer) 0
redis 127.0.0.1:6379> HGET myhash field1
"foo"

redis 127.0.0.1:6379> HSETNX nosql key-value-store redis
(integer) 1

redis 127.0.0.1:6379> HSETNX nosql key-value-store redis       # 操作无效, key-value-store 已存在
(integer) 0

查看更多 Redis 哈希(Hash)命令

Beginning ARKit for iPhone and iPad

Beginning ARKit for iPhone and iPad

Wallace Wang / Apress / 2018-11-5 / USD 39.99

Explore how to use ARKit to create iOS apps and learn the basics of augmented reality while diving into ARKit specific topics. This book reveals how augmented reality allows you to view the screen on ......一起来看看 《Beginning ARKit for iPhone and iPad》 这本书的介绍吧!

HTML 压缩/解压工具

HTML 压缩/解压工具

在线压缩/解压 HTML 代码

CSS 压缩/解压工具

CSS 压缩/解压工具

在线压缩/解压 CSS 代码

RGB HSV 转换

RGB HSV 转换

RGB HSV 互转工具