public class UniqueCacheRepository<T,K extends java.io.Serializable> extends OrmRepository<T,K>
应用于两种情况:
1.没有PlayerId注解的实体类.
2.有PlayerId注解并且和Id注解同一个属性的实体类.
可以理解为,一个角色只有一条记录或不属于任何角色的数据的类.
| 限定符和类型 | 字段和说明 |
|---|---|
protected AsyncWriteService |
asyncWriteService |
protected DataCache<T,K> |
dataCache |
dataAccessor, entityMapping| 构造器和说明 |
|---|
UniqueCacheRepository() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected DataCache<T,K> |
buildDataCache(int offlineInterval)
创建数据缓存.
|
void |
cacheDelete(K entityId)
从缓存中删除指定Id的对象.
|
void |
cacheDelete(T entity)
删除缓存一个对象.
|
void |
cacheDeleteAll()
删除当前模块全部缓存对象.
|
T |
cacheGet(K entityId)
从缓存中Get指定ID的对象
|
void |
cacheInsert(T entity)
保存一个新增对象到缓存.
|
java.util.Optional<T> |
cacheLoad(K entityId)
从缓存中Load指定ID的对象
|
java.util.List<T> |
cacheLoadAll()
从缓存中获取所有缓存数据.
|
java.util.List<T> |
cacheLoadAll(java.util.function.Predicate<T> filter)
根据条件从缓存中获取所有缓存数据.
|
void |
cacheUpdate(T entity)
修改缓存中的数据.
|
void |
checkEntityAndInitCache()
检查实体类与DB映射关系并初始化缓存
|
EntityMapping<T> |
getEntityMapping()
获取当前OrmRepository的实体类的描述对象
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitload, loadAll, loadAllprotected DataCache<T,K extends java.io.Serializable> dataCache
@Autowired protected AsyncWriteService asyncWriteService
public void cacheDelete(K entityId)
entityId - 缓存对象的Idpublic java.util.Optional<T> cacheLoad(K entityId)
entityId - 缓存对象的Idpublic java.util.List<T> cacheLoadAll(java.util.function.Predicate<T> filter)
filter - 条件protected DataCache<T,K> buildDataCache(int offlineInterval)
offlineInterval - 离线缓存时间public EntityMapping<T> getEntityMapping()
getEntityMapping 在接口中 CacheRepository<T,K extends java.io.Serializable>public void checkEntityAndInitCache()
OrmRepositorycheckEntityAndInitCache 在类中 OrmRepository<T,K extends java.io.Serializable>public void cacheInsert(T entity)
entity - 新增对象.public void cacheDelete(T entity)
entity - 实体对象.public void cacheDeleteAll()
这是删除全部,调用时,别犯2
public void cacheUpdate(T entity)
entity - 实体对象.public java.util.List<T> cacheLoadAll()