【SpringBoot学习】24-@CachePut 更新数据 同步缓存

@CachePut 会在方法完成后 将数据添加至缓存
在这里插入图片描述

 @Update("UPDATE `user` SET `username` = #{username}, `real_name` =  #{realName}, `password` = #{password}, `gender` =#{gender},  `user_type` = #{userType} WHERE `id` = #{id}")
    int updateUser (User user);
 @CachePut(cacheNames = "user",key = "#user.id")
    public User updateUser(User user){
        userMapper.updateUser(user);
        return user;
    }

@GetMapping("/updateUser")
    public User updateUser(User user){
        userService.updateUser(user);
        return user;
    }
发布了130 篇原创文章 · 获赞 8 · 访问量 2848

猜你喜欢

转载自blog.csdn.net/ange2000561/article/details/104876015
今日推荐