Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Memcached delete command


May 17, 2021 Memcached



The Memcached delete command is used to remove keys that already exist.

Grammar:

The basic syntax of the delete command is as follows:

delete key [noreply]

Multiple keys are separated by spaces, as follows:

delete key1 key2 key3

The parameters are described below:

  • Key: Key in the key-value structure to find cached values.
  • Noreply (optional): This parameter tells the server that no data needs to be returned

Instance

In the following example, we use w3cschool as key, with an expiration time set to 900 seconds. We then use the delete command to remove the key.

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

Output

Output information description:

  • DELETED: The deletion was successful.
  • ERROR: Syntax error or deletion failed.
  • NOT_FOUND:key does not exist.