By using the get command, you can get the value of the key.
Syntax
Example
In the given example, we use javatpoint as the key and store Memcached in it with an expiration time of 900 seconds.
- import net.spy.memcached.MemcachedClient;
- public class MemcachedJava {
- public static void main(String[] args) {
-
- 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("javatpoint", 900, "memcached").done);
-
-
- System.out.println("Get from Cache:"+mcc.get("javatpoint"));
- }
- }