diff --git a/src/main/java/com/zcloud/util/CaffeineUtil.java b/src/main/java/com/zcloud/util/CaffeineUtil.java index d6eb9a4..9556434 100644 --- a/src/main/java/com/zcloud/util/CaffeineUtil.java +++ b/src/main/java/com/zcloud/util/CaffeineUtil.java @@ -22,30 +22,6 @@ import java.util.logging.Logger; @Component public class CaffeineUtil { private static final Logger logger = Logger.getLogger(CaffeineUtil.class.getName()); - @Resource - private DictionariesMapper dictionariesMapper; - - @Bean(name = "caffeineCache") - public Cache caffeineCache() { - Cache build = Caffeine.newBuilder() - //8小时没有读写自动删除 - .expireAfterAccess(8, TimeUnit.HOURS) - // 当垃圾收集器需要释放内存时驱逐 - .softValues() - //最大容量1个,超过会自动清理空间 - .maximumSize(1) - .removalListener(((key, value, cause) -> { - //清理通知 key,value ==> 键值对 cause ==> 清理原因 - System.out.printf("Key %s was removed (%s)%n", key, cause); - })).build(); - // 加载一次 - build.get("xzqh", x -> { - List all = dictionariesMapper.getAll(); - Map fileSort = AdministrativeUntil.getFileSort(all); - return fileSort; - }); - return build; - } /** * @Description: 登录token @@ -67,22 +43,4 @@ public class CaffeineUtil { })).build(); return loginToken; } - - - /** - * @Description: 行政区划 - * @Author: dearLin - * @Date: 2023/6/12/012 9:25 - * @Param: [com.github.benmanes.caffeine.cache.Cache] [build] - * @Return: void - */ - @Async - public void loadOnce(Cache build) { - // 加载一次 - build.get("xzqh", x -> { - List all = dictionariesMapper.getAll(); - Map fileSort = AdministrativeUntil.getFileSort(all); - return fileSort; - }); - } }