简体   繁体   中英

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

ran into a strange issue, I annotated my controller with @Transactional(just for testing) and it took me by surprise that internally when it hits the method with @cacheable annotation it is not creating any cache keys

@Transactional
@RequestMapping(value = "/auth", method = RequestMethod.POST)
public void createAuth() {
    ApplicationContextProvider.getApplicationContext().getBean(GeographyServiceHelper.class).getAggregatedClusterData(1);
}

method with @cacheable issue.

@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}

Internally geography service helper calls api manager directly with forceReload = false.

Am I missing something silly?

嘿伙计,只需等待事务提交,您就会看到想要看到的内容。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM