本文内容为 http://redis.io/commands/del 的翻译、注解、例子扩充及其它修改。感谢 Redis 作者 Antirez 为开源社区作出的贡献,本文保证最新、最准、最全以表示对其的敬意。欢迎留言纠错、提示更新或支持。
DEL key [key ...]

删除指定键 key,如果该键不存在则忽略。

Removes the specified keys. A key is ignored if it does not exist.
  • 被删除键的数量。

    The number of keys that were removed.
  • redis> SET key1 "Hello"
    OK
    redis> SET key2 "World"
    OK
    redis> DEL key1 key2 key3
    (integer) 2
  • 版本支持

    1.0.0+

    时间复杂度(Time complexity)

    O(N)N 为将被删除的键的数量。

    O(N) where N is the number of keys that will be removed. When a key to remove holds a value other than a string, the individual complexity for this key is O(M) where M is the number of elements in the list, set, sorted set or hash. Removing a single key that holds a string value is O(1).