取消缓存

This commit is contained in:
2026-08-20 12:43:06 +08:00
parent 0e859f2c87
commit 8d4a32c75c
2 changed files with 2 additions and 56 deletions
@@ -48,14 +48,5 @@ public interface IComSchTreeService {
Map<Integer,List<SelectIntVO>> getSchGroupTypeList(Integer schId, int type);
/**
* 清除全部缓存(Redis 组树/学校列表 + 本地内存缓存)
*/
void clearCache();
/**
* 清除指定学校的缓存(学校组树 + 全局缓存)
* @param schId 学校ID,为 null 时等同清除全部
*/
void clearCache(Integer schId);
}
@@ -80,18 +80,6 @@ public class ComSchTreeService implements IComSchTreeService {
idToNameCache = null;
}
/**
* 清除指定学校的缓存(学校组树 + 全局缓存)
* @param schId 学校ID,为 null 时等同清除全部
*/
public void clearCache(Integer schId) {
if (schId != null) {
redisUtil.del(RedisConstants.SCHOOL_TREE + "_" + schId);
}
// 学校树变更可能影响学校列表/全局组树,一并清除
clearCache();
}
/**
* 获取基础学制映射(带双重检查锁)
*/
@@ -129,16 +117,6 @@ public class ComSchTreeService implements IComSchTreeService {
}
// public List<BoaGroup> getSchTree(Integer schId) {
// BoaGroup group = YschBaseOpenApi.getGroupById(schId,true);
// return Collections.singletonList(group);
//// String cacheKey = RedisConstants.SCHOOL_TREE + "_" + schId;
//// String json = redisUtil.get(cacheKey,String.class);
//// List<BoaGroup> treeList = OtherUtil.jsonParseArrayTree(json, BoaGroup.class);
//// return treeList;
// }
public String getSchoolName(Integer schId) {
if (schId == null) {
return null;
@@ -270,31 +248,8 @@ public class ComSchTreeService implements IComSchTreeService {
}
public List<BoaGroup> getSchTree(Integer schId) {
String cacheKey= RedisConstants.SCHOOL_TREE+"_"+schId;
List<BoaGroup> cached = redisUtil.getList(cacheKey, BoaGroup.class);
if (cached != null && !cached.isEmpty()) {
return cached;
}
// 2. 加锁防止缓存击穿 + 双重检查
synchronized (this) {
cached = redisUtil.getList(cacheKey, BoaGroup.class);
if (cached != null && !cached.isEmpty()) {
return cached;
}
// 3. 从数据库查询
BoaGroup schGroup = YschBaseOpenApi.getGroupById(schId,true);
List<BoaGroup> list=Collections.singletonList(schGroup);
// 4. 仅缓存非空结果;空结果不缓存,防止空缓存污染(穿透风险可忽略)
if (!list.isEmpty()) {
redisUtil.set(cacheKey,list, RedisConstants.CACHE_EXPIRE_1M);
}
return list;
}
BoaGroup schGroup = YschBaseOpenApi.getGroupById(schId,true);
return Collections.singletonList(schGroup);
}
public List<SelectIntVO> getSchoolList() {