提交 e3a59b76 编写于 作者: Z zengqiao

修复数据删空之后, 缓存不能被更新的BUG

上级 b67a162d
......@@ -78,13 +78,14 @@ public class AppDaoImpl implements AppDao {
* 更新APP缓存
*/
private synchronized void updateTopicCache(List<AppDO> doList, long timestamp) {
if (APP_CACHE_LATEST_UPDATE_TIME == Constant.START_TIMESTAMP) {
APP_MAP.clear();
}
if (doList == null || doList.isEmpty() || APP_CACHE_LATEST_UPDATE_TIME >= timestamp) {
// 本次无数据更新, 或者本次更新过时 时, 忽略本次更新
return;
}
if (APP_CACHE_LATEST_UPDATE_TIME == Constant.START_TIMESTAMP) {
APP_MAP.clear();
}
for (AppDO elem: doList) {
APP_MAP.put(elem.getAppId(), elem);
......
......@@ -93,7 +93,7 @@ public class AuthorityDaoImpl implements AuthorityDao {
private void updateAuthorityCache() {
Long timestamp = System.currentTimeMillis();
long timestamp = System.currentTimeMillis();
if (timestamp + 1000 <= AUTHORITY_CACHE_LATEST_UPDATE_TIME) {
// 近一秒内的请求不走db
......@@ -109,13 +109,14 @@ public class AuthorityDaoImpl implements AuthorityDao {
* 更新Topic缓存
*/
private synchronized void updateAuthorityCache(List<AuthorityDO> doList, Long timestamp) {
if (AUTHORITY_CACHE_LATEST_UPDATE_TIME == Constant.START_TIMESTAMP) {
AUTHORITY_MAP.clear();
}
if (doList == null || doList.isEmpty() || AUTHORITY_CACHE_LATEST_UPDATE_TIME >= timestamp) {
// 本次无数据更新, 或者本次更新过时 时, 忽略本次更新
return;
}
if (AUTHORITY_CACHE_LATEST_UPDATE_TIME == Constant.START_TIMESTAMP) {
AUTHORITY_MAP.clear();
}
for (AuthorityDO elem: doList) {
Map<Long, Map<String, AuthorityDO>> doMap =
......
......@@ -92,7 +92,7 @@ public class TopicDaoImpl implements TopicDao {
}
private void updateTopicCache() {
Long timestamp = System.currentTimeMillis();
long timestamp = System.currentTimeMillis();
if (timestamp + 1000 <= TOPIC_CACHE_LATEST_UPDATE_TIME) {
// 近一秒内的请求不走db
......@@ -108,13 +108,14 @@ public class TopicDaoImpl implements TopicDao {
* 更新Topic缓存
*/
private synchronized void updateTopicCache(List<TopicDO> doList, Long timestamp) {
if (TOPIC_CACHE_LATEST_UPDATE_TIME == Constant.START_TIMESTAMP) {
TOPIC_MAP.clear();
}
if (doList == null || doList.isEmpty() || TOPIC_CACHE_LATEST_UPDATE_TIME >= timestamp) {
// 本次无数据更新, 或者本次更新过时 时, 忽略本次更新
return;
}
if (TOPIC_CACHE_LATEST_UPDATE_TIME == Constant.START_TIMESTAMP) {
TOPIC_MAP.clear();
}
for (TopicDO elem: doList) {
Map<String, TopicDO> doMap = TOPIC_MAP.getOrDefault(elem.getClusterId(), new ConcurrentHashMap<>());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册