如下:不能将缓存注解加在listCate(boolean isShowHide)方法上
因为spring是使用AOP的方法获取缓存,在一个bean中再去调用别一个方法,不会应用缓存
@Cacheable(value = "cate_cache", cacheManager = "basicInfoCacheManager",key = "#root.methodName")
@Override
public List
return listCate(true);
}
@Cacheable(value = "cate_cache", cacheManager = "basicInfoCacheManager",key = "#root.methodName")
@Override
public List
return listCate(false);
}
private List
return gcList=dao.listValidGoodsCate();
}
Spring Cache的一些限制:基于接口调用cache才有效
同时清除多个不同的key
@Caching(evict = {
@CacheEvict(allEntries = true, value = "cate_batch_cache"),
@CacheEvict(value = "cate_cache",key = "#categoryDto.getId()")
})