memcached gets command is used to get the value with cas token. if the key does not exist in memcached, then it returns nothing.
syntax
the basic syntax of memcached gets command is as shown below −
get key
example
set tutorialspoint 0 900 9 memcached stored gets tutorialspoint value tutorialspoint 0 9 1 memcached end
in this example, we use tutorialspoint as the key and store memcached in it with an expiration time of 900 seconds.
get cas data using java application
to get cas data from a memcached server, you need to use the memcached gets method.
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("tutorialspoint", 900, "memcached").done);
// get value from cache
system.out.println("get from cache:"+mcc.gets("tutorialspoint"));
}
}
output
on compiling and executing the program, you get to see the following output −
connection to server successfully
set status:true
get from cache:{casvalue 2/memcached}