Back to Redis

UNLINK

content/commands/unlink.md

latest1.6 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 >}}

This command is very similar to [DEL]({{< relref "/commands/del" >}}): it removes the specified keys. Just like [DEL]({{< relref "/commands/del" >}}) a key is ignored if it does not exist. However the command performs the actual memory reclaiming in a different thread, so it is not blocking, while [DEL]({{< relref "/commands/del" >}}) is. This is where the command name comes from: the command just unlinks the keys from the keyspace. The actual removal will happen later asynchronously.

Examples

{{% redis-cli %}} SET key1 "Hello" SET key2 "World" UNLINK 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="unlink-return-info" tab1="RESP2" tab2="RESP3" >}}

Integer reply: the number of keys that were unlinked.

-tab-sep-

Integer reply: the number of keys that were unlinked.

{{< /multitabs >}}