@CacheEvict 清除多个key

借用@Caching实现
入参是基本类型的:

@Caching(evict={
    
    @CacheEvict(value = Cache.CONSTANT, key = "'" + CacheKey.SINGLE_ROLE_NAME + "'+#roleId"),
            @CacheEvict(value = Cache.CONSTANT, key = "'" + CacheKey.ROLES_NAME + "'+#roleId"),
            @CacheEvict(value = Cache.CONSTANT, key = "'" + CacheKey.SINGLE_ROLE_NAME + "'+#roleId")})
public ResponseData remove(@RequestParam Long roleId) {
    
    
………………
}

入参是对象的:

@Caching(evict={
    
    @CacheEvict(value = Cache.CONSTANT, key = "'" + CacheKey.SINGLE_ROLE_NAME + "'+#roleDto.roleId"),
            @CacheEvict(value = Cache.CONSTANT, key = "'" + CacheKey.ROLES_NAME + "'+#roleDto.roleId"),
            @CacheEvict(value = Cache.CONSTANT, key = "'" + CacheKey.SINGLE_ROLE_NAME + "'+#roleDto.roleId")})
    public ResponseData edit(RoleDto roleDto) {
    
    
        this.roleService.editRole(roleDto);
        return SUCCESS_TIP;
    }

参考链接:https://blog.csdn.net/Amy126/article/details/88661773

猜你喜欢

转载自blog.csdn.net/qq_25983579/article/details/110933857