Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复添加修改用户没有清除邮件接收人缓存问题 #27

Merged
merged 1 commit into from
Nov 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -65,6 +67,7 @@ public class UserService {
public Result<User> 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);
Expand Down Expand Up @@ -141,6 +144,7 @@ public Result<Integer> 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);
Expand Down Expand Up @@ -273,12 +277,12 @@ public Result<User> query(long id) {
* @param user
*/
public String queryMonitorEmail() {
Object email = mqLocalCache.get("monitor");
Object email = mqLocalCache.get(MONITOR_CACHE_KEY);
if (email == null) {
List<User> 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) {
Expand Down