【业务功能89】补充【业务功能88】:微服务-springcloud-分布式锁-springcache- @CacheEvict

@CacheEvict:在更新数据的时候同步删除缓存中的数据

    /**
     * @CacheEvict:在更新数据的时候同步删除缓存中的数据
     * @CacheEvict(value = "catagory",allEntries = true) 表示删除catagory分区下的所有的缓存数据
     * @param entity
     */
    //@CacheEvict(value = "catagory",key="'getLeve1Category'")
    /*@Caching(evict = {
            @CacheEvict(value = "catagory",key="'getLeve1Category'")
            ,@CacheEvict(value = "catagory",key="'getCatelog2JSON'")
    })*/
    @CacheEvict(value = "catagory",allEntries = true)
    @Transactional
    @Override
    public void updateDetail(CategoryEntity entity) {
    
    
        // 更新类别名称
        this.updateById(entity);
        if(!StringUtils.isEmpty(entity.getName())){
    
    
            // 同步更新级联的数据
            categoryBrandRelationService.updateCatelogName(entity.getCatId(),entity.getName());
            // TODO 同步更新其他的冗余数据
        }
    }

猜你喜欢

转载自blog.csdn.net/studyday1/article/details/132578273