Back to Redis

DEL

content/commands/del.md

latest1.5 KB
Original Source

{{< note >}} This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. {{< /note >}}

Removes the specified keys. A key is ignored if it does not exist.

Examples

{{< clients-example set="cmds_generic" step="del" description="Foundational: Delete one or more keys using DEL (ignores non-existent keys, returns count of deleted keys)" difficulty="beginner" >}}

SET key1 "Hello" "OK" SET key2 "World" "OK" DEL key1 key2 key3 (integer) 2 {{< /clients-example >}}

Give these commands a try in the interactive console:

{{% redis-cli %}} SET key1 "Hello" SET key2 "World" DEL key1 key2 key3 {{% /redis-cli %}}

Redis Software and Redis Cloud compatibility

| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | |

Return information

{{< multitabs id="del-return-info" tab1="RESP2" tab2="RESP3" >}}

Integer reply: the number of keys that were removed.

-tab-sep-

Integer reply: the number of keys that were removed.

{{< /multitabs >}}