Memcached - Delete Key
Memcached delete command is used to delete an existing key from the Memcached server. It means it removes an item from the cache if it exists.
key: It is the key data stored and retrieved from Memcached.
noreply: It is an optional parameter. It is used to inform the server not to send any reply.
This command will return the following value:
DELETED: Means successful deletion.
ERROR: It shows error while deleting data or when the syntax is wrong.
NOT_FOUND: shows that the key does not exist in the Memcached server.
Example in Ubuntu
Let's see an example for the delete command. Here we will use 'city' as the key and store 'bangalore' in it with the expiration of time 900 seconds. After this, delete command is used to delete the key 'city.'
Example in Windows:
Delete data using Java Application
Let's consider Memcached server is running on host 127.0.0.1 and port 11211. Here, we will use delete() method to delete the data from a Memcached server.
Connection to server successful set status: true Get from Cache: Bangalore Delete from Cache: true Get from Cache: null
Connection to server successful set status:true javatpoint value in cache - largest online tutorials library delete status:true javatpoint value in cache - null