Memcached - Delete KeyMemcached 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. SyntaxHere, 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. Return ValueThis 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 UbuntuLet'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:Memcached Server: Memcached Client: Delete data using Java ApplicationLet'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. Example 1Output: Connection to server successful set status: true Get from Cache: Bangalore Delete from Cache: true Get from Cache: null Example 2Output: Connection to server successful set status:true javatpoint value in cache - largest online tutorials library delete status:true javatpoint value in cache - null
Next Topic#
|