接口 SuperCacheService<Id extends Serializable,Entity extends SuperEntity<?>>

类型参数:
Id - ID
Entity - 实体
所有超级接口:
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
  • 方法详细资料

    • getByIdCache

      Entity getByIdCache(Id id)
      根据id 先查缓存,再查db
      参数:
      id - 主键
      返回:
      对象
    • getByKey

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

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

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

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