-
Notifications
You must be signed in to change notification settings - Fork 279
快速入门
dennis zhuang edited this page Jul 28, 2016
·
1 revision
如果您使用maven构建,只需要添加依赖即可使用xmemcached:
<dependency>
<groupId>com.googlecode.xmemcached</groupId>
<artifactId>xmemcached</artifactId>
<version>版本号</version>
</dependency>
MemcachedClient client=new XMemcachedClient("host",11211);
//同步存储value到memcached,缓存超时为1小时,3600秒。
client.set("key",3600,someObject);
//从memcached获取key对应的value
Object someObject=client.get("key");
//从memcached获取key对应的value,操作超时2秒
someObject=client.get("key",2000);
//更新缓存的超时时间为10秒。
boolean success=client.touch("key",10);
//删除value
client.delete("key");
更多请阅读用户指南