LocalOverCache.java 661 B

123456789101112131415161718192021222324252627
  1. package com.fdkankan.openApi.aop;
  2. import cn.hutool.cache.CacheUtil;
  3. import cn.hutool.cache.impl.TimedCache;
  4. import cn.hutool.core.date.DateUnit;
  5. import org.springframework.stereotype.Component;
  6. /**
  7. * @author Xiewj
  8. * @date 2023/2/17
  9. */
  10. @Component
  11. public class LocalOverCache {
  12. /**
  13. * jvm内存缓存, 并发情况,可以减少redis连接
  14. */
  15. final TimedCache<String, Boolean> timedCache = CacheUtil.newTimedCache(DateUnit.DAY.getMillis() * 1);
  16. public Boolean getTimedCache(String key) {
  17. return timedCache.get(key);
  18. }
  19. public void setTimedCache(String key, Boolean flag) {
  20. timedCache.put(key, flag);
  21. }
  22. }