当从 spring 引导中具有 @transactional 注释的方法调用时,@Cacheable 不创建缓存键

@Cacheable not creating cache keys when called from a method having @transactional annotation in spring boot

运行 变成了一个 st运行ge 问题,我用 @T运行sactional 注释了我的控制器(只是为了测试),当它发生时内部让我感到惊讶带有@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 管理器。

我是不是漏掉了什么愚蠢的东西?

嘿伙计,等待事务提交,你会看到你想看到的。