del[orm]: remove duplicate definition method persist() and updateNow()

This commit is contained in:
godotg
2024-06-21 18:38:59 +08:00
parent 22d6ad4ee0
commit 4dffdda93a
2 changed files with 1 additions and 30 deletions
+1 -23
View File
@@ -246,34 +246,12 @@ public class EntityCache<PK extends Comparable<PK>, E extends IEntity<PK>> imple
}
}
});
persistList(updateList, entityClass);
}
@Override
public void persist(PK pk) {
var pnode = cache.get(pk);
if (pnode == null) {
return;
}
@SuppressWarnings("unchecked")
var entityClass = (Class<E>) entityDef.getClazz();
var updateList = new ArrayList<E>();
var currentTime = TimeUtils.currentTimeMillis();
if (pnode.getModifiedTime() == pnode.getWriteToDbTime()) {
return;
}
var entity = pnode.getEntity();
pnode.setWriteToDbTime(currentTime);
pnode.setModifiedTime(currentTime);
updateList.add(entity);
persistList(updateList, entityClass);
}
private void persistList(ArrayList<E> updateList, Class<E> entityClass) {
// 执行更新
if (updateList.isEmpty()) {
return;
}
var page = Page.valueOf(1, BATCH_SIZE, updateList.size());
var maxPageSize = page.totalPage();
@@ -66,13 +66,6 @@ public interface IEntityCache<PK extends Comparable<PK>, E extends IEntity<PK>>
*/
void invalidate(PK pk);
/**
* 持久化缓存数据
*
* @param pk 主键
*/
void persist(PK pk);
/**
* 持久化所有缓存数据
*/