mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-22 15:05:06 +08:00
1. 配置的缓存刷新机制
This commit is contained in:
@ -28,6 +28,8 @@ public class DBConfigRepository extends AbstractConfigRepository {
|
||||
|
||||
private final static ScheduledExecutorService m_executorService;
|
||||
|
||||
private static DBConfigRepository INSTANCE;
|
||||
|
||||
static {
|
||||
m_executorService = Executors.newScheduledThreadPool(1,
|
||||
ApolloThreadFactory.create(DBConfigRepository.class.getSimpleName(), true));
|
||||
@ -64,6 +66,19 @@ public class DBConfigRepository extends AbstractConfigRepository {
|
||||
this.trySync();
|
||||
// 初始化定时任务
|
||||
this.schedulePeriodicRefresh();
|
||||
|
||||
// 设置单例
|
||||
INSTANCE = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知同步,
|
||||
*/
|
||||
public static void noticeSync() {
|
||||
// 提交到线程池中,避免和 schedulePeriodicRefresh 并发问题
|
||||
m_executorService.submit(() -> {
|
||||
INSTANCE.trySync();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -127,7 +142,6 @@ public class DBConfigRepository extends AbstractConfigRepository {
|
||||
Tracer.logEvent("Apollo.Client.Version", Apollo.VERSION);
|
||||
}, m_configUtil.getRefreshInterval(), m_configUtil.getRefreshInterval(),
|
||||
m_configUtil.getRefreshIntervalTimeUnit());
|
||||
// TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
// ========== 数据库相关操作 ==========
|
||||
|
Reference in New Issue
Block a user