//初始化緩存
cache =
CacheBuilder.newBuilder()
.maximumSize(picInfoCacheMaximumSize)
.expireAfterAccess(picInfoCacheExpireAfterAccess, TimeUnit.SECONDS)
.removalListener(new MyRemovalListener())
.build();
//監聽刪除
private class MyRemovalListener implements RemovalListener<String, String> {
[@Override](https://my.oschina.net/u/1162528)
public void onRemoval(RemovalNotification<String, String> notification) {
String tips = String.format("key=%s,value=%s,reason=%s", notification.getKey(), notification.getValue(), notification.getCause());
log.info(" removalListener " + tips);
}
}
guava 使用(com.google.common.cache)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.