Let's understand the syntax:set key flags exptime bytes [noreply] value
Here is the Java code example.
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 sucessfully");
System.out.println("set status:"+mcc.set("city", 900, "Bangalore").done);
//Get value from cache
System.out.println("Get from Cache:"+mcc.get("Bangalore"));
}
}