Written by - Yash Agrawal

memcached delete key


This is used to remove the key from Memcached server.If the key is not present nothing happens.

Example:

delete key [noreply]

Java Code:

import net.spy.memcached.MemcachedClient;  
public class MemcachedJava {  
   public static void main(String[] args) {  
        
      // Connecting to Memcached server on localhost  
      MemcachedClient mcc = new MemcachedClient(new  
      InetSocketAddress("127.0.0.1", 11211));  
      System.out.println("Connection to server successful");  
      System.out.println("set status:"+mcc.set("city", 900, "bangalore").done);  
        
      // Get value from cache  
      System.out.println("Get from Cache:"+mcc.get("city"));  
        
      // delete value from cache  
      System.out.println("Delete from Cache:"+mcc.delete("city").isDone());  
        
      // check whether value exists or not  
      System.out.println("Get from Cache:"+mcc.get("city"));  
   }  
}