【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;
    }

版权声明:本文为ange2000561原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。