From 508ad76cb87014339caa4a25cbfc440104c6b131 Mon Sep 17 00:00:00 2001 From: zhangjiayu Date: Thu, 3 Aug 2023 18:08:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DMailAccountService=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0/=E5=88=A0=E9=99=A4=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E6=9C=AA=E6=B8=85=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/system/service/mail/MailAccountServiceImpl.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailAccountServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailAccountServiceImpl.java index 457056f40c..adb16a8119 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailAccountServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailAccountServiceImpl.java @@ -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);