Skip to content

Commit

Permalink
update redis cached service
Browse files Browse the repository at this point in the history
  • Loading branch information
cuilan committed May 14, 2024
1 parent 582a009 commit 92da49d
Showing 1 changed file with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ public interface CachedService<T> extends IService<T> {
*/
List<T> getCacheListByIds(Collection<Long> ids);

/**
* 查询自定义key集合,缓存中不存在,则查库
*
* @param keys keys
* @return 返回对象List
*/
List<T> getCacheListByKeys(Collection<String> keys);

/**
* 查询id集合,缓存中不存在,则插库
*
Expand All @@ -63,6 +71,14 @@ public interface CachedService<T> extends IService<T> {
*/
Map<Long, T> getCacheMapByIds(Collection<Long> ids);

/**
* 查询自定义key集合,缓存中不存在,则插库
*
* @param keys keys
* @return 返回对象Map,key:主键,value:实体对象
*/
Map<String, T> getCacheMapByKeys(Collection<String> keys);

/**
* 清除缓存
*/
Expand All @@ -85,11 +101,32 @@ public interface CachedService<T> extends IService<T> {
void saveOrUpdateCache(String key, T t);

/**
* 获取缓存中全部对象
* 查询所有Long类型id的缓存
*
* @return ConcurrentMap
* @return 实体对象集合
*/
ConcurrentMap<String, T> getAllCache();
List<T> getAllCacheById();

/**
* 查询所有String类型自定义key的缓存
*
* @return 实体对象集合
*/
List<T> getAllCacheByKey();

/**
* 获取所有Long类型自定义key的缓存
*
* @return ConcurrentMap&lt;Long, T&gt;
*/
ConcurrentMap<Long, T> getAllCacheMapById();

/**
* 获取所有String类型自定义key的缓存
*
* @return ConcurrentMap&lt;String, T&gt;
*/
ConcurrentMap<String, T> getAllCacheMapByKey();

/**
* 缓存中不存在时,默认执行此方法
Expand Down Expand Up @@ -122,4 +159,5 @@ default List<T> daoGetByIdList(Collection<Long> collection) {
// 需要子类自定义实现
throw new BaseException(ErrorCode.CACHE_SERVICE_UNAVAILABLE);
}

}

0 comments on commit 92da49d

Please sign in to comment.