初学者指南:http://code.google.com/p/xmemcached/wiki/User_Guide_zh#使用指南
新命令介绍: http://code.google.com/p/memcached/wiki/NewCommands
下载地址:http://code.google.com/p/memcached/downloads/list
在linux 下安装memcatch:
http://www.ccvita.com/257.html
http://www.2cto.com/os/201203/125164.html
http://www.cnblogs.com/sunson/archive/2012/04/07/2436086.html (详细)
MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil.getAddresses("localhost:11211"));
MemcachedClient memcachedClient = builder.build();
try {
memcachedClient.set("hello", 0, "Hello,xmemcached");
String value = memcachedClient.get("hello");
System.out.println("hello=" + value);
memcachedClient.delete("hello");
value = memcachedClient.get("hello");
System.out.println("hello=" + value);
} catch (MemcachedException e) {
System.err.println("MemcachedClient operation fail");
e.printStackTrace();
} catch (TimeoutException e) {
System.err.println("MemcachedClient operation timeout");
e.printStackTrace();
} catch (InterruptedException e) {
// ignore
}
try {
//close memcached client
memcachedClient.shutdown();
} catch (IOException e) {
System.err.println("Shutdown MemcachedClient fail");
e.printStackTrace();
}
maven配置
<dependency>
<groupId>com.googlecode.xmemcached</groupId>
<artifactId>xmemcached</artifactId>
<version>1.3.8</version>
</dependency>