HEXISTS 是一个 Redis 命令,用于检查哈希表(Hash)中是否存在指定的字段(field)
用法如下:
HEXISTS key field
其中:
key 是哈希表的名称。field 是要检查的字段名称。返回值:
示例:
students 的哈希表,并添加一些字段:HSET students name "Alice" age 25
HSET students gender "female"
HSET students city "New York"
HEXISTS 命令检查 students 哈希表中是否存在 age、gender 和 country 字段:HEXISTS students age
# 返回 1,因为 `age` 字段存在于哈希表中
HEXISTS students gender
# 返回 1,因为 `gender` 字段存在于哈希表中
HEXISTS students country
# 返回 0,因为 `country` 字段不存在于哈希表中