!49 修复MailAccountService 更新/删除缓存未清空

Merge pull request !49 from ZJY/fix_redisCache
This commit is contained in:
芋道源码 2023-08-05 06:42:25 +00:00 committed by Gitee
commit eeeac1a627
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
import cn.iocoder.yudao.module.system.dal.mysql.mail.MailAccountMapper;
import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -46,7 +47,8 @@ public class MailAccountServiceImpl implements MailAccountService {
}
@Override
@Cacheable(value = RedisKeyConstants.MAIL_ACCOUNT, key = "#updateReqVO.id")
@CacheEvict(value = RedisKeyConstants.MAIL_ACCOUNT,
allEntries = true)// allEntries 清空所有缓存主要一次更新涉及到的 mailAccountId 较多反倒批量会更快
public void updateMailAccount(MailAccountUpdateReqVO updateReqVO) {
// 校验是否存在
validateMailAccountExists(updateReqVO.getId());
@ -57,7 +59,8 @@ public class MailAccountServiceImpl implements MailAccountService {
}
@Override
@Cacheable(value = RedisKeyConstants.MAIL_ACCOUNT, key = "#id")
@CacheEvict(value = RedisKeyConstants.MAIL_ACCOUNT,
allEntries = true)// allEntries 清空所有缓存主要一次更新涉及到的 mailAccountId 较多反倒批量会更快
public void deleteMailAccount(Long id) {
// 校验是否存在账号
validateMailAccountExists(id);