From c7cfb274436ceedb6af82c58e00be4a90d5dd1de Mon Sep 17 00:00:00 2001 From: zhangyanli Date: Wed, 13 Mar 2024 08:41:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B1=E9=80=9A=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/zcloud/util/CaffeineUtil.java | 42 ------------------- 1 file changed, 42 deletions(-) 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; - }); - } }