package com.tiesheng.util; import cn.hutool.cache.CacheUtil; import cn.hutool.cache.impl.TimedCache; public class TimedCacheHelper { private static volatile TimedCache timedCache; /** * 获取一个默认2分钟过期的缓存 */ public static TimedCache getTimedCache() { if (timedCache == null) { synchronized (TimedCacheHelper.class) { if (timedCache == null) { timedCache = CacheUtil.newTimedCache(2 * 60 * 1000); timedCache.schedulePrune(1000); } } } return timedCache; } }