Memcached delete command

The Memcached delete command is used to delete an existing key.

Syntax:

The basic syntax of the delete command is as follows:

delete key [noreply]

The parameter description is as follows:

  • key:The key in the key-value structure, used to look up the cached value.
  • noreply (optional): This parameter tells the server not to return data.

Example

In the following example, we use example as the key and set the expiration time to 900 seconds. After that, we use the delete command to delete the key.

set example 0 900 9
memcached
STORED
get example
VALUE example 0 9
memcached
END
delete example
DELETED
get example
END
delete example
NOT_FOUND

Output

Output information description:

  • DELETED: Deleted successfully.
  • ERROR: Syntax error or deletion failed.
  • NOT_FOUND: The key does not exist.
Other extensions