类 SuperCacheServiceImpl<M extends SuperCacheManager<Entity>,Id extends Serializable,Entity extends SuperEntity<?>>
java.lang.Object
top.tangyh.basic.base.service.impl.SuperServiceImpl<M,Id,Entity>
top.tangyh.basic.base.service.impl.SuperCacheServiceImpl<M,Id,Entity>
- 类型参数:
M- ManagerId- IDEntity- 实体
- 所有已实现的接口:
SuperCacheService<Id,,Entity> SuperService<Id,Entity>
public abstract class SuperCacheServiceImpl<M extends SuperCacheManager<Entity>,Id extends Serializable,Entity extends SuperEntity<?>>
extends SuperServiceImpl<M,Id,Entity>
implements SuperCacheService<Id,Entity>
基于 CacheOps 实现的 缓存实现
默认的key规则: #{CacheKeyBuilder#key()}:id
1,getByIdCache:新增的方法: 先查缓存,在查db 2,removeById:重写 ServiceImpl 类的方法,删除db后,淘汰缓存 3,removeByIds:重写 ServiceImpl 类的方法,删除db后,淘汰缓存 4,updateAllById: 新增的方法: 修改数据(所有字段)后,淘汰缓存 5,updateById:重写 ServiceImpl 类的方法,修改db后,淘汰缓存
- 作者:
- zuihou
-
字段概要
字段从类继承的字段 top.tangyh.basic.base.service.impl.SuperServiceImpl
entityClass, idClass, managerClass, superManager -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidclearCache(List<Long> ids) 清理缓存findByIds(Collection<? extends Serializable> ids, Function<Collection<? extends Serializable>, Collection<Entity>> loader) 可能会缓存穿透getByIdCache(Id id) 根据id 先查缓存,再查db根据 key 查询缓存中存放的id,缓存不存在根据loader加载并写入数据,然后根据查询出来的id查询 实体voidrefreshCache(List<Long> ids) 刷新缓存从类继承的方法 top.tangyh.basic.base.service.impl.SuperServiceImpl
copy, currentIdClass, currentManagerClass, currentModelClass, getById, getEntityClass, getIdClass, getSuperManager, list, listByIds, page, removeByIds, save, saveAfter, saveBatch, saveBefore, updateAfter, updateAllAfter, updateAllBefore, updateAllById, updateBefore, updateById从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 top.tangyh.basic.base.service.SuperService
copy, getById, getEntityClass, getIdClass, getSuperManager, list, listByIds, page, removeByIds, save, saveBatch, updateAllById, updateById
-
字段详细资料
-
cacheOps
-
-
构造器详细资料
-
SuperCacheServiceImpl
public SuperCacheServiceImpl()
-
-
方法详细资料
-
getByIdCache
从接口复制的说明:SuperCacheService根据id 先查缓存,再查db- 指定者:
getByIdCache在接口中SuperCacheService<M extends SuperCacheManager<Entity>,Id extends Serializable> - 参数:
id- 主键- 返回:
- 对象
-
findByIds
@Transactional(readOnly=true) public List<Entity> findByIds(@NonNull Collection<? extends Serializable> ids, Function<Collection<? extends Serializable>, Collection<Entity>> loader) 从接口复制的说明:SuperCacheService可能会缓存穿透- 指定者:
findByIds在接口中SuperCacheService<M extends SuperCacheManager<Entity>,Id extends Serializable> - 参数:
ids- 主键idloader- 回调- 返回:
- 对象集合
-
getByKey
@Transactional(readOnly=true) public Entity getByKey(CacheKey key, Function<CacheKey, Object> loader) 从接口复制的说明:SuperCacheService根据 key 查询缓存中存放的id,缓存不存在根据loader加载并写入数据,然后根据查询出来的id查询 实体- 指定者:
getByKey在接口中SuperCacheService<M extends SuperCacheManager<Entity>,Id extends Serializable> - 参数:
key- 缓存keyloader- 加载器- 返回:
- 对象
-
refreshCache
从接口复制的说明:SuperCacheService刷新缓存- 指定者:
refreshCache在接口中SuperCacheService<M extends SuperCacheManager<Entity>,Id extends Serializable> - 参数:
ids- 主键
-
clearCache
从接口复制的说明:SuperCacheService清理缓存- 指定者:
clearCache在接口中SuperCacheService<M extends SuperCacheManager<Entity>,Id extends Serializable> - 参数:
ids- 主键
-