语法
hdel key_name field1...field2...fieldn
可用版本
>=2.0.0.
返回值
返回从哈希中删除的字段的个数,如果字段不存在则返回0。
返回值类型
整数
例子1:删除单个
127.0.0.1:6379> hmset langhash lang1 "PHP" lang2 "JavaScript" lang3 "Python"
OK
127.0.0.1:6379> hget langhash lang1
"PHP"
127.0.0.1:6379> hget langhash lang2
"JavaScript"
127.0.0.1:6379> hget langhash lang3
"Python"
127.0.0.1:6379> hdel langhash lang1
(integer) 1
127.0.0.1:6379> hget langhash lang1
(nil)
127.0.0.1:6379> hget langhash lang2
"JavaScript"
127.0.0.1:6379> hget langhash lang3
"Python"
例子2:删除多个
127.0.0.1:6379> hmset langhash lang1 "PHP" lang2 "JavaScript" lang3 "Python"
OK
127.0.0.1:6379> hget langhash lang1
"PHP"
127.0.0.1:6379> hget langhash lang2
"JavaScript"
127.0.0.1:6379> hget langhash lang3
"Python"
127.0.0.1:6379> hdel langhash lang1 lang2 lang3
(integer) 3
127.0.0.1:6379> hget langhash lang1
(nil)
127.0.0.1:6379> hget langhash lang2
(nil)
127.0.0.1:6379> hget langhash lang3
(nil)