Interface SuperCacheService<Id extends Serializable,Entity extends SuperEntity<?>>

Type Parameters:
Id - ID
Entity - 实体
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 Details

    • getByIdCache

      Entity getByIdCache(Id id)
      根据id 先查缓存,再查db
      Parameters:
      id - 主键
      Returns:
      对象
    • getByKey

      Entity getByKey(CacheKey key, Function<CacheKey,Object> loader)
      根据 key 查询缓存中存放的id,缓存不存在根据loader加载并写入数据,然后根据查询出来的id查询 实体
      Parameters:
      key - 缓存key
      loader - 加载器
      Returns:
      对象
    • findByIds

      List<Entity> findByIds(@NonNull Collection<? extends Serializable> ids, Function<Collection<? extends Serializable>,Collection<Entity>> loader)
      可能会缓存穿透
      Parameters:
      ids - 主键id
      loader - 回调
      Returns:
      对象集合
    • refreshCache

      void refreshCache(List<Long> ids)
      刷新缓存
      Parameters:
      ids - 主键
    • clearCache

      void clearCache(List<Long> ids)
      清理缓存
      Parameters:
      ids - 主键