package com.tiesheng.util;

import cn.hutool.cache.CacheUtil;
import cn.hutool.cache.impl.TimedCache;

public class TimedCacheHelper {

    private static volatile TimedCache<String, String> timedCache;

    /**
     * 获取一个默认2分钟过期的缓存
     */
    public static TimedCache<String, String> getTimedCache() {
        if (timedCache == null) {
            synchronized (TimedCacheHelper.class) {
                if (timedCache == null) {
                    timedCache = CacheUtil.newTimedCache(2 * 60 * 1000);
                    timedCache.schedulePrune(1000);
                }
            }
        }
        return timedCache;
    }

}
