From 99ec709b095fb29632291b62fc10a480950546fa Mon Sep 17 00:00:00 2001 From: zhangaochong Date: Thu, 28 Oct 2021 19:14:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E6=B2=A1=E6=9C=89=E6=B8=85?= =?UTF-8?q?=E9=99=A4=E9=82=AE=E4=BB=B6=E6=8E=A5=E6=94=B6=E4=BA=BA=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/sohu/tv/mq/cloud/service/UserService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mq-cloud/src/main/java/com/sohu/tv/mq/cloud/service/UserService.java b/mq-cloud/src/main/java/com/sohu/tv/mq/cloud/service/UserService.java index d675449a..dbf1c756 100644 --- a/mq-cloud/src/main/java/com/sohu/tv/mq/cloud/service/UserService.java +++ b/mq-cloud/src/main/java/com/sohu/tv/mq/cloud/service/UserService.java @@ -38,6 +38,8 @@ public class UserService { private Logger logger = LoggerFactory.getLogger(this.getClass()); + private static final String MONITOR_CACHE_KEY = "monitor"; + @Autowired private UserDao userDao; @@ -65,6 +67,7 @@ public class UserService { public Result save(User user) { try { userDao.insert(user); + mqLocalCache.cleanUp(MONITOR_CACHE_KEY); } catch (DuplicateKeyException e) { logger.warn("duplicate key:{}", user); return Result.getResult(Status.DB_DUPLICATE_KEY); @@ -141,6 +144,7 @@ public Result update(User user) { if(user.getEmail() != null) { userLocalCache.cleanUp(user.getEmail()); } + mqLocalCache.cleanUp(MONITOR_CACHE_KEY); } catch (Exception e) { logger.error("update err, user:{}", user, e); return Result.getDBErrorResult(e); @@ -273,12 +277,12 @@ public Result query(long id) { * @param user */ public String queryMonitorEmail() { - Object email = mqLocalCache.get("monitor"); + Object email = mqLocalCache.get(MONITOR_CACHE_KEY); if (email == null) { List userList = queryMonitorUser(); if (userList != null && userList.size() > 0) { email = Jointer.BY_COMMA.join(userList, u -> u.getEmail()); - mqLocalCache.put("monitor", email); + mqLocalCache.put(MONITOR_CACHE_KEY, email); } } if (email == null) {