google的缓存,用起来很方便,功能强大
例子
//缓存offerVos
private static LoadingCache<String, List<OfferVO>> offerVosCache
= CacheBuilder.newBuilder().
//设置10s没有更新数据则会移除数据
expireAfterWrite(15, TimeUnit.SECONDS).
//设置缓存个数,达到则开始使用LRU策略回收
maximumSize(1000).
//移除时回调函数
removalListener(removalListener).
build(cacheLoader);
}
这里只用了其部分功能
本文转自whk66668888 51CTO博客,原文链接:http://blog.51cto.com/12597095/1953214