w3resource

Redis Keys: DEL

Redis DEL Command

The Redis DEL command is used to remove the specified keys. A key is ignored if it does not exist.

Here are some common uses and scenarios for the "DEL" command:

  • Key Removal: Delete one or more keys from the database.
  • Cache Management: Remove expired or unwanted cached data.
  • Cleanup: Clear out temporary or obsolete data.
  • Space Management: Free up memory by deleting unnecessary keys.

Syntax:

DEL key [key ...]

Available since

1.0.0.

Return Value

Integer Reply: Number of keys that were removed.

Return Value Type

Integer

Example: Redis DEL

First, create a key in redis and set some value in it. and then delete the created keys.

127.0.0.1:6379> SET key "Good"
OK
127.0.0.1:6379> SET key1 "Morning"
OK
127.0.0.1:6379> DEL key key1 key2
(integer) 2

Previous: Redis Data Types
Next: DUMP



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/redis/redis-del-key.php