// 创建缓存对象
private static MemCachedClient cachedClient = new MemCachedClient();
// 创建缓存连接池
static {
SockIOPool pool = SockIOPool.getInstance();
pool.setServers(new String[] { "127.0.0.1:11211" });
pool.setFailover(true);
pool.setInitConn(10); // 设置初始连接
pool.setMinConn(5);// 设置最小连接
pool.setMaxConn(250); // 设置最大连接
pool.setMaxIdle(1000 * 60 * 60 * 3); // 设置每个连接最大空闲时间3个小时
pool.setMaintSleep(30);
pool.setNagle(false);
pool.setSocketTO(3000);
pool.setAliveCheck(true);
pool.initialize();
}
public static void main(String[] args) {
//添加缓存
cachedClient.add("cc", "123fffffffffffff");
//删除缓存
cachedClient.delete("cc");
//获取缓存
System.out.println(cachedClient.get("cc"));
}