mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-10 02:22:37 +00:00
feat[cache]: get the data in the cache
This commit is contained in:
@@ -176,6 +176,15 @@ public class EntityCache<PK extends Comparable<PK>, E extends IEntity<PK>> imple
|
||||
return cachePnode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E get(PK pk) {
|
||||
PNode<PK, E> cachePnode = caches.get(pk);
|
||||
if (cachePnode == null) {
|
||||
return null;
|
||||
}
|
||||
return cachePnode.getEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(E entity) {
|
||||
var cachePnode = fetchCachePnode(entity, true);
|
||||
|
||||
@@ -38,6 +38,13 @@ public interface IEntityCache<PK extends Comparable<PK>, E extends IEntity<PK>>
|
||||
*/
|
||||
E loadOrCreate(PK pk);
|
||||
|
||||
/**
|
||||
* EN: Get the data in the cache or returns null if it does not exist in the cache.
|
||||
* CN: 获取缓存中的数据,如果缓存中不存在则返回null。
|
||||
*/
|
||||
@Nullable
|
||||
E get(PK pk);
|
||||
|
||||
/**
|
||||
* 更新缓存中的数据,只更新缓存的时间戳,并通过一定策略写入到数据库
|
||||
* <p>
|
||||
|
||||
Reference in New Issue
Block a user