0 votes
in MemCached by
How to get the value of key?

1 Answer

0 votes
by

By using the get command, you can get the value of the key.

Syntax

  1. get key  

Example

In the given example, we use javatpoint as the key and store Memcached in it with an expiration time of 900 seconds.

  1. import net.spy.memcached.MemcachedClient;  
  2. public class MemcachedJava {  
  3.    public static void main(String[] args) {  
  4.       // Connecting to Memcached server on localhost  
  5.       MemcachedClient mcc = new MemcachedClient(new  
  6.       InetSocketAddress("127.0.0.1", 11211));  
  7.       System.out.println("Connection to server sucessfully");  
  8.       System.out.println("set status:"+mcc.set("javatpoint", 900, "memcached").done);  
  9.        
  10.      // Get value from cache  
  11.       System.out.println("Get from Cache:"+mcc.get("javatpoint"));  
  12.    }  
  13. }  

Related questions

0 votes
asked Jun 15, 2022 in MemCached by sharadyadav1986
0 votes
asked Jul 29, 2023 in MemCached by sharadyadav1986
...