Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Redis · Command

DEL

DEL removes one or more specified keys and ignores names that do not exist. It returns the count of keys successfully deleted.

How it works

DEL removes every named key that currently exists. Missing keys are ignored, and the command reports how many keys it actually removed. Supplying multiple keys lets one command delete several cache entries.

Syntax

DEL key [key ...]

Parameters

NameTypeDescription
keykeyThe first key to remove; required.
key ...keyZero or more additional keys to remove.

Returns

Integer reply: the number of keys that were removed.

Key points

  • DEL deletes one or more named keys from the Redis keyspace.
  • The command requires one key and optionally accepts additional keys.
  • The integer reply counts only keys that were actually present and deleted.
  • Redis classifies DEL as a keyspace and write command, and marks it as slow.
  • Its running time grows with the number of keys removed.

Common mistakes

  • Deleting a nonexistent key does not produce an error or increase the returned deletion count.
  • In cluster deployments, multi-key deletion can have different behavior; consider Redis cluster multi-key operation rules.

Example: Delete cache keys

SET session:123 "active"
DEL session:123 session:missing
EXISTS session:123

Creates a key, removes it along with a nonexistent key, then verifies that the existing key is gone.

When to use it

Cache invalidation

Remove a cached response after its source data changes.

Session revocation

Invalidate a session or token immediately during logout.

Batch cleanup

Clean up several related temporary keys in one request.

Interview questions

QWhat does DEL return?

DEL accepts one or more keys and removes the ones that exist. Its integer result is the number of keys removed, so missing keys contribute zero.

Follow-up: How would you avoid blocking the server while removing a very large value? Use UNLINK when asynchronous reclamation is preferable.

QWhat is the syntax of DEL?

The command syntax is DEL key [key ...]. The first key is required, and the bracketed repetition permits additional keys in the same command.

Follow-up: What constraint matters when deleting several keys in a cluster? Keys may need to satisfy the cluster's multi-key operation requirements.

QWhat operational concern does DEL have?

DEL has O(N) time complexity, where N is the number of keys being removed. It is categorized by Redis as a keyspace write command with slow-command classification.

Follow-up: What alternative has the same deletion purpose but moves memory reclamation away from the main execution path? UNLINK.

  • EXISTS
  • GET
  • SET
  • UNLINK

Source: DEL | Docs. Checked 2026-10-16.