M - T - public abstract class SuperCacheServiceImpl<M extends SuperMapper<T>,T> extends SuperServiceImpl<M,T> implements SuperCacheService<T>
1,getByIdCache:新增的方法: 先查缓存,在查db 2,removeById:重写 ServiceImpl 类的方法,删除db后,淘汰缓存 3,removeByIds:重写 ServiceImpl 类的方法,删除db后,淘汰缓存 4,updateAllById: 新增的方法: 修改数据(所有字段)后,淘汰缓存 5,updateById:重写 ServiceImpl 类的方法,修改db后,淘汰缓存
| 限定符和类型 | 字段和说明 |
|---|---|
protected CacheOps |
cacheOps |
protected static int |
MAX_BATCH_KEY_SIZE |
| 构造器和说明 |
|---|
SuperCacheServiceImpl() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected abstract CacheKeyBuilder |
cacheKeyBuilder()
缓存key 构造器
|
void |
clearCache()
清理缓存
|
protected void |
delCache(Collection<?> idList) |
protected void |
delCache(Serializable... ids) |
protected void |
delCache(T model) |
List<T> |
findByIds(Collection<? extends Serializable> ids,
Function<Collection<? extends Serializable>,Collection<T>> loader)
可能会缓存穿透
|
T |
getByIdCache(Serializable id)
根据id 先查缓存,再查db
|
T |
getByKey(CacheKey key,
Function<CacheKey,Object> loader)
根据 key 查询缓存中存放的id,缓存不存在根据loader加载并写入数据,然后根据查询出来的id查询 实体
|
protected Object |
getId(T model) |
void |
refreshCache()
刷新缓存
|
boolean |
removeById(Serializable id) |
boolean |
removeByIds(Collection<?> idList) |
boolean |
save(T model) |
boolean |
saveBatch(Collection<T> entityList,
int batchSize) |
boolean |
saveOrUpdateBatch(Collection<T> entityList,
int batchSize) |
protected void |
setCache(T model) |
boolean |
updateAllById(T model)
根据id修改 entity 的所有字段
|
boolean |
updateBatchById(Collection<T> entityList,
int batchSize) |
boolean |
updateById(T model) |
getEntityClass, getSuperMapper, handlerSave, handlerUpdateAllById, handlerUpdateByIdcloseSqlSession, currentMapperClass, currentModelClass, executeBatch, executeBatch, executeBatch, getBaseMapper, getMap, getObj, getOne, getSqlStatement, removeBatchByIds, removeBatchByIds, removeById, retBool, saveOrUpdate, sqlSessionBatch, sqlStatementclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetEntityClass, saveBatchSomeColumncount, count, getBaseMapper, getById, getMap, getObj, getOne, getOne, ktQuery, ktUpdate, lambdaQuery, lambdaUpdate, list, list, listByIds, listByMap, listMaps, listMaps, listObjs, listObjs, listObjs, listObjs, page, page, pageMaps, pageMaps, query, remove, removeBatchByIds, removeBatchByIds, removeBatchByIds, removeBatchByIds, removeById, removeById, removeByIds, removeByMap, saveBatch, saveOrUpdate, saveOrUpdate, saveOrUpdateBatch, update, update, update, updateBatchById@Autowired protected CacheOps cacheOps
protected static final int MAX_BATCH_KEY_SIZE
protected abstract CacheKeyBuilder cacheKeyBuilder()
@Transactional(readOnly=true) public T getByIdCache(Serializable id)
SuperCacheServicegetByIdCache 在接口中 SuperCacheService<T>id - 主键@Transactional(readOnly=true) public List<T> findByIds(@NonNull Collection<? extends Serializable> ids, Function<Collection<? extends Serializable>,Collection<T>> loader)
SuperCacheServicefindByIds 在接口中 SuperCacheService<T>ids - 主键idloader - 回调@Transactional(readOnly=true) public T getByKey(CacheKey key, Function<CacheKey,Object> loader)
SuperCacheServicegetByKey 在接口中 SuperCacheService<T>key - 缓存keyloader - 加载器@Transactional(rollbackFor=java.lang.Exception.class) public boolean removeById(Serializable id)
removeById 在接口中 com.baomidou.mybatisplus.extension.service.IService<T>removeById 在类中 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl<M extends SuperMapper<T>,T>@Transactional(rollbackFor=java.lang.Exception.class) public boolean removeByIds(Collection<?> idList)
removeByIds 在接口中 com.baomidou.mybatisplus.extension.service.IService<T>removeByIds 在类中 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl<M extends SuperMapper<T>,T>@Transactional(rollbackFor=java.lang.Exception.class) public boolean save(T model)
save 在接口中 com.baomidou.mybatisplus.extension.service.IService<T>save 在类中 SuperServiceImpl<M extends SuperMapper<T>,T>@Transactional(rollbackFor=java.lang.Exception.class) public boolean updateAllById(T model)
SuperServiceupdateAllById 在接口中 SuperService<T>updateAllById 在类中 SuperServiceImpl<M extends SuperMapper<T>,T>@Transactional(rollbackFor=java.lang.Exception.class) public boolean updateById(T model)
updateById 在接口中 com.baomidou.mybatisplus.extension.service.IService<T>updateById 在类中 SuperServiceImpl<M extends SuperMapper<T>,T>@Transactional(rollbackFor=java.lang.Exception.class) public boolean saveBatch(Collection<T> entityList, int batchSize)
saveBatch 在接口中 com.baomidou.mybatisplus.extension.service.IService<T>saveBatch 在类中 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl<M extends SuperMapper<T>,T>@Transactional(rollbackFor=java.lang.Exception.class) public boolean saveOrUpdateBatch(Collection<T> entityList, int batchSize)
saveOrUpdateBatch 在接口中 com.baomidou.mybatisplus.extension.service.IService<T>saveOrUpdateBatch 在类中 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl<M extends SuperMapper<T>,T>@Transactional(rollbackFor=java.lang.Exception.class) public boolean updateBatchById(Collection<T> entityList, int batchSize)
updateBatchById 在接口中 com.baomidou.mybatisplus.extension.service.IService<T>updateBatchById 在类中 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl<M extends SuperMapper<T>,T>public void refreshCache()
SuperCacheServicerefreshCache 在接口中 SuperCacheService<T>public void clearCache()
SuperCacheServiceclearCache 在接口中 SuperCacheService<T>protected void delCache(Serializable... ids)
protected void delCache(Collection<?> idList)
protected void delCache(T model)
protected void setCache(T model)
Copyright © 2022. All rights reserved.