快速入门

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");

更多请阅读用户指南

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.