HDEL

Syntax
HDEL key field [field ...]
Available since:
2.0.0
Time complexity:
O(N) where N is the number of fields to be removed.
ACL categories:
@write, @hash, @fast,

从存储在key的哈希中移除指定的字段。 如果哈希中不存在指定的字段,则忽略这些字段。 如果没有字段剩余,则删除该哈希。 如果key不存在,则将其视为空哈希,并且此命令返回0

示例

HSET myhash field1 "foo" HDEL myhash field1 HDEL myhash field2

RESP2 回复

Integer reply: the number of fields that were removed from the hash, excluding any specified but non-existing fields.

RESP3 回复

Integer reply: The number of fields that were removed from the hash, excluding any specified but non-existing fields.

历史

  • 从 Redis 2.4.0 版本开始:接受多个 field 参数。
RATE THIS PAGE
Back to top ↑