@Cacheable(sync=true) only allows a single cache on

楔子

学习笔记,做个总结,希望不要误导人。

@Cacheable(sync=true) only allows a single cache on

    @Cacheable(value = {"cahce:menu", "mu"}, key = "'sysMenu'", sync = true)//|https://cloud.tencent.com/developer/article/1497596
//代表 当前方法的结果需要缓存,如果缓存中有,方法不调用,如果缓存中没有,查询后彷如缓存
    @Override
    public List<MenuStream> getAllwithJ8Stream() {
        log.info("menu with java8stream  by  mysql db");
        // 使用java8 stream 封装父子关系,来展示 ztree 标准JSON格式
        List<MenuStream> queryForList = jtemplate.query("select id,pId ,name,url,icon from t_menu", new BeanPropertyRowMapper(MenuStream.class));

        // 获取取根节点
        List<MenuStream> collect = queryForList.stream().filter((menu) -> {
            return menu.getPid() == null;
        }).map((menu) -> {
            menu.setChildren(getChildren(menu, queryForList));
            return menu;
        }).sorted((m1, m2) -> {
            return m1.getId() - m2.getId();
        }).collect(Collectors.toList());
        System.out.println(collect);
        return collect;
    }

org.springframework.cache.interceptor.CacheAspectSupport.CacheOperationContexts#determineSyncFlag

@Cacheable(sync=true) only allows a single cache on_第1张图片

 @Cacheable(value = {"cahce:menu", "mu"}, key = "'sysMenu'", sync = true
调整为

 @Cacheable(value = {"cahce:menu"}, key = "'sysMenu'", sync = true

你可能感兴趣的:(springboot)