【发布时间】:2019-07-01 15:16:40
【问题描述】:
遇到了一个奇怪的问题,我用 @Transactional 注释了我的控制器(仅用于测试),令我惊讶的是,当它在内部使用 @cacheable 注释命中方法时,它没有创建任何缓存键
@Transactional
@RequestMapping(value = "/auth", method = RequestMethod.POST)
public void createAuth() {
ApplicationContextProvider.getApplicationContext().getBean(GeographyServiceHelper.class).getAggregatedClusterData(1);
}
@cacheable 问题的方法。
@Cacheable(value = "getAllClusterHierarchyHash", key = "\"all_cluster_hirerarchy_map\"", unless = CONDITION_NULL,
cacheNames = "getAllClusterHierarchyHash")
@CacheEvict(value = "getAllClusterHierarchyHash", key = "\"all_cluster_hirerarchy_map\"",
condition = "#forceReload", cacheNames = "getAllClusterHierarchyHash", beforeInvocation = true)
public Map<Integer, ClusterDetails> getAllClusterHierarchyHash(Boolean forceReload) {// do something}
内部地理服务助手直接使用 forceReload = false 调用 api 管理器。
我错过了什么傻事吗?
【问题讨论】:
标签: java spring caching spring-transactions