Skip to content

Commit

Permalink
perf[entity]: persist entity with different version strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysunxiao committed Jul 29, 2024
1 parent ee43b08 commit 4bc8650
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions orm/src/main/java/com/zfoo/orm/cache/EntityCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,6 @@ private void persistAndCompareVersion(List<E> updateList) {
// 如果没有版本号,则直接更新数据库
var entityVersion = wrapper.gvs(entity);
var dbEntityVersion = wrapper.gvs(dbEntity);
if (entityVersion <= 0) {
OrmContext.getAccessor().update(entity);
continue;
}

// 如果版本号相同,说明已经更新到
if (dbEntityVersion == entityVersion) {
Expand All @@ -383,7 +379,7 @@ private void persistAndCompareVersion(List<E> updateList) {
// 数据库版本号较大,说明缓存的数据不是最新的,直接清除缓存,下次重新加载
cache.remove(id);
load(id);
logger.warn("[database:{}] document of entity [id:{}] version [{}] is greater than cache [vs:{}]", clazz.getSimpleName(), id, dbEntityVersion, entityVersion);
logger.warn("[database:{}] document of entity [id:{}] version [{}] is greater than cache [vs:{}] and reload db entity to cache", clazz.getSimpleName(), id, dbEntityVersion, entityVersion);
}
}

Expand Down

0 comments on commit 4bc8650

Please sign in to comment.