DEL
Delete one or more keys.
Syntax
DEL key [key ...]Description
The DEL command removes one or more keys from Echo DB. If a key does not exist, it is ignored. The command returns the number of keys that were actually removed.
Arguments
key(required, one or more): The name(s) of the key(s) to delete.
Return Value
Returns an Integer: The number of keys that were removed.
Examples
Deleting a Single Key
SET mykey "value"
DEL mykeyResponse:
OK
(integer) 1Deleting Multiple Keys
SET key1 "value1"
SET key2 "value2"
SET key3 "value3"
DEL key1 key2 key3Response:
OK
OK
OK
(integer) 3Deleting Non-Existent Keys
DEL nonexistent1 nonexistent2Response:
(integer) 0Mixed Existing and Non-Existent Keys
SET key1 "value1"
DEL key1 nonexistent key2Response:
OK
(integer) 1Notes
DELworks with both string and list keys- Non-existent keys are ignored (not counted as deleted)
- The command is atomic - all specified keys are deleted in a single operation
- Returns
0if no keys were deleted
Use Cases
- Cleanup: Remove temporary or expired data
- Cache Invalidation: Delete cached entries
- Data Management: Remove keys that are no longer needed
- Bulk Operations: Delete multiple keys at once