feat[orm]: persist the entity of the specified key

This commit is contained in:
godotg
2024-06-24 17:44:22 +08:00
parent e82f3b3a1c
commit 568c3c4c8a
2 changed files with 16 additions and 0 deletions
+9
View File
@@ -227,6 +227,15 @@ public class EntityCache<PK extends Comparable<PK>, E extends IEntity<PK>> imple
cache.remove(pk);
}
@Override
public void persist(PK pk) {
var pnode = cache.get(pk);
if (pnode == null) {
return;
}
updateUnsafeNow(pnode.getEntity());
}
// 游戏中80%都是执行更新的操作,这样做会极大的提高更新速度
@Override
public void persistAll() {
@@ -66,6 +66,13 @@ public interface IEntityCache<PK extends Comparable<PK>, E extends IEntity<PK>>
*/
void invalidate(PK pk);
/**
* 持久化缓存数据
*
* @param pk 主键
*/
void persist(PK pk);
/**
* 持久化所有缓存数据
*/