系统邮件一分钟从数据库中取一次
parent
02124be971
commit
5724c775ec
|
|
@ -16,8 +16,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
public class MailingSystemManager {
|
public class MailingSystemManager {
|
||||||
|
|
||||||
private static Map<Integer, MailingSystem> mailingSystemMap = new ConcurrentHashMap<>();
|
private static Map<Integer, MailingSystem> mailingSystemMap = new ConcurrentHashMap<>();
|
||||||
|
private static long preLoadTime = 0;
|
||||||
|
private static long resetTime = 60*1000;
|
||||||
public static void init(ConfigurableApplicationContext configurableApplicationContext) throws Exception {
|
public static void init(ConfigurableApplicationContext configurableApplicationContext) throws Exception {
|
||||||
//TODO 测试用
|
//TODO 测试用
|
||||||
//初始化系统邮件信息
|
//初始化系统邮件信息
|
||||||
|
|
@ -43,7 +43,13 @@ public class MailingSystemManager {
|
||||||
return mailingSystemMap.containsKey(id);
|
return mailingSystemMap.containsKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MailingSystem getMailingSystem() {
|
public static MailingSystem getMailingSystem() throws Exception {
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
if (now - preLoadTime > resetTime){
|
||||||
|
MailingSystem mailingSystem = MongoUtil.getInstence().getMyMongoTemplate().findById(MailingSystem.getCollectionName(), GameApplication.serverId, MailingSystem.class);
|
||||||
|
mailingSystemMap.put(GameApplication.serverId,mailingSystem);
|
||||||
|
preLoadTime = now;
|
||||||
|
}
|
||||||
return mailingSystemMap.get(GameApplication.serverId);
|
return mailingSystemMap.get(GameApplication.serverId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ public class MailLogic {
|
||||||
* 获取所有系统邮件
|
* 获取所有系统邮件
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private List<SystemMail> getSystemMail() {
|
private List<SystemMail> getSystemMail() throws Exception {
|
||||||
MailingSystem mailingSystem = MailingSystemManager.getMailingSystem();
|
MailingSystem mailingSystem = MailingSystemManager.getMailingSystem();
|
||||||
SystemMailManager systemMailManager = mailingSystem.getSystemMailManager();
|
SystemMailManager systemMailManager = mailingSystem.getSystemMailManager();
|
||||||
Map<Integer, SystemMail> systemMailMap = systemMailManager.getSystemMailMap();
|
Map<Integer, SystemMail> systemMailMap = systemMailManager.getSystemMailMap();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue