private static InputStream is = null;
private static CacheManager cm = null ;
static{
is = MyCacheManager.class.getClassLoader().getResourceAsStream(Constant.EHCACHE_CONFIG_NAME);
cm = CacheManager.create(is);
}
public static CacheManager getInstance(){
return cm;
}
}
//PUT 这里数据是能正常的缓存到内存中的
Cache cache = MyCacheManager.getInstance().getCache("simpleCache");
Element ele = new Element(“cacheData”,data) ;
cache.put(ele);
//GET 这里在一段时间后就取不到数据了
Element ele = MyCacheManager.getCache("simpleCache").get("cacheData");