mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-05-19 13:27:10 +00:00
perf[orm]: updates entity are not verified for consistency
This commit is contained in:
+10
-3
@@ -139,10 +139,7 @@ public class EntityCache<PK extends Comparable<PK>, E extends IEntity<PK>> imple
|
||||
|
||||
@Override
|
||||
public void update(E entity) {
|
||||
AssertionUtils.notNull(entity);
|
||||
|
||||
var currentPnode = cache.getIfPresent(entity.id());
|
||||
|
||||
if (currentPnode == null) {
|
||||
currentPnode = new PNode<>(entity);
|
||||
cache.put(entity.id(), currentPnode);
|
||||
@@ -168,6 +165,16 @@ public class EntityCache<PK extends Comparable<PK>, E extends IEntity<PK>> imple
|
||||
currentPnode.setModifiedTime(TimeUtils.now() + 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUnsafe(E entity) {
|
||||
var currentPnode = cache.getIfPresent(entity.id());
|
||||
if (currentPnode == null) {
|
||||
currentPnode = new PNode<>(entity);
|
||||
cache.put(entity.id(), currentPnode);
|
||||
}
|
||||
currentPnode.setModifiedTime(TimeUtils.now() + 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNow(E entity) {
|
||||
update(entity);
|
||||
|
||||
@@ -32,6 +32,11 @@ public interface IEntityCache<PK extends Comparable<PK>, E extends IEntity<PK>>
|
||||
*/
|
||||
void update(E entity);
|
||||
|
||||
/**
|
||||
* 同update(),不会校验更新的线程是否一致
|
||||
*/
|
||||
void updateUnsafe(E entity);
|
||||
|
||||
/**
|
||||
* 更新缓存中的数据,立刻写入到数据库
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user