Package top.tangyh.basic.base.service
Interface SuperCacheService<Id extends Serializable,Entity extends SuperEntity<?>>
- Type Parameters:
Id- IDEntity- 实体
- All Superinterfaces:
SuperService<Id,Entity>
- All Known Implementing Classes:
SuperCacheServiceImpl
public interface SuperCacheService<Id extends Serializable,Entity extends SuperEntity<?>>
extends SuperService<Id,Entity>
基于MP的 IService 新增了3个方法: getByIdCache
其中:
1,getByIdCache 方法 会先从缓存查询,后从DB查询 (取决于实现类)
2、SuperService 上的方法
- Author:
- zuihou
-
Method Summary
Modifier and TypeMethodDescriptionvoidclearCache(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) 刷新缓存Methods inherited from interface top.tangyh.basic.base.service.SuperService
copy, getById, getEntityClass, getIdClass, getSuperManager, list, listByIds, page, removeByIds, save, saveBatch, updateAllById, updateById
-
Method Details
-
getByIdCache
根据id 先查缓存,再查db- Parameters:
id- 主键- Returns:
- 对象
-
getByKey
根据 key 查询缓存中存放的id,缓存不存在根据loader加载并写入数据,然后根据查询出来的id查询 实体- Parameters:
key- 缓存keyloader- 加载器- Returns:
- 对象
-
findByIds
List<Entity> findByIds(@NonNull Collection<? extends Serializable> ids, Function<Collection<? extends Serializable>, Collection<Entity>> loader) 可能会缓存穿透- Parameters:
ids- 主键idloader- 回调- Returns:
- 对象集合
-
refreshCache
刷新缓存- Parameters:
ids- 主键
-
clearCache
清理缓存- Parameters:
ids- 主键
-