package com.dxhy.erp.utils;

import java.util.concurrent.TimeUnit;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;

/**
 * @author dxhy
 */
public class CacheUtilBase {

    public static <T, V> LoadingCache<T, V> init(long expireSecond, long maxNum, CacheLoader<T, V> cacheLoad) {
        return CacheBuilder.newBuilder().expireAfterWrite(expireSecond, TimeUnit.SECONDS).maximumSize(maxNum).weakKeys()
            .build(cacheLoad);
    }
}
