接口 SuperCacheService<Id extends Serializable,Entity extends SuperEntity<?>>
- 类型参数:
Id- IDEntity- 实体
- 所有超级接口:
SuperService<Id,Entity>
- 所有已知实现类:
SuperCacheServiceImpl
public interface SuperCacheService<Id extends Serializable,Entity extends SuperEntity<?>>
extends SuperService<Id,Entity>
基于MP的 IService 新增了3个方法: getByIdCache
其中:
1,getByIdCache 方法 会先从缓存查询,后从DB查询 (取决于实现类)
2、SuperService 上的方法
- 作者:
- zuihou
-
方法概要
修饰符和类型方法说明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.SuperService
copy, getById, getEntityClass, getIdClass, getSuperManager, list, listByIds, page, removeByIds, save, saveBatch, updateAllById, updateById
-
方法详细资料
-
getByIdCache
根据id 先查缓存,再查db- 参数:
id- 主键- 返回:
- 对象
-
getByKey
根据 key 查询缓存中存放的id,缓存不存在根据loader加载并写入数据,然后根据查询出来的id查询 实体- 参数:
key- 缓存keyloader- 加载器- 返回:
- 对象
-
findByIds
List<Entity> findByIds(@NonNull Collection<? extends Serializable> ids, Function<Collection<? extends Serializable>, Collection<Entity>> loader) 可能会缓存穿透- 参数:
ids- 主键idloader- 回调- 返回:
- 对象集合
-
refreshCache
刷新缓存- 参数:
ids- 主键
-
clearCache
清理缓存- 参数:
ids- 主键
-