自己写的不完整的cacheUtils工具类,做下笔记, 之所以叫cacheUtils2,因为cacheUtils不能用,
package test;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class CacheUtils2 {
//初始化一个XXX
private static Map> pool = new ConcurrentHashMap>();
private static String name;
private static int maxNumber;
public static CacheUtils2 instance(String name, int maxNumber) {
CacheUtils2 cacheUtils = new CacheUtils2();
cacheUtils.name = name;
cacheUtils.maxNumber = maxNumber;
return cacheUtils;
}
public static void add(String key, String value) {
Map oldCache = pool.get(name);
if (oldCache == null) {
Map newCache = new LinkedHashMap();
newCache.put(key, value);