diff --git a/src/main/java/com/yunhai/bschclassmanage/service/IComSchTreeService.java b/src/main/java/com/yunhai/bschclassmanage/service/IComSchTreeService.java index 43ff91c..e8795b4 100644 --- a/src/main/java/com/yunhai/bschclassmanage/service/IComSchTreeService.java +++ b/src/main/java/com/yunhai/bschclassmanage/service/IComSchTreeService.java @@ -48,14 +48,5 @@ public interface IComSchTreeService { Map> getSchGroupTypeList(Integer schId, int type); - /** - * 清除全部缓存(Redis 组树/学校列表 + 本地内存缓存) - */ void clearCache(); - - /** - * 清除指定学校的缓存(学校组树 + 全局缓存) - * @param schId 学校ID,为 null 时等同清除全部 - */ - void clearCache(Integer schId); } diff --git a/src/main/java/com/yunhai/bschclassmanage/service/impl/com/ComSchTreeService.java b/src/main/java/com/yunhai/bschclassmanage/service/impl/com/ComSchTreeService.java index 6a4a2aa..25b9534 100644 --- a/src/main/java/com/yunhai/bschclassmanage/service/impl/com/ComSchTreeService.java +++ b/src/main/java/com/yunhai/bschclassmanage/service/impl/com/ComSchTreeService.java @@ -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 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 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 getSchTree(Integer schId) { - String cacheKey= RedisConstants.SCHOOL_TREE+"_"+schId; - List 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 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 getSchoolList() {