> iterator = cacheMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entryentry = iterator.next();
if (expireTimeMap.containsKey(entry.getKey())) {
long expireTime = expireTimeMap.get(key);
if (System.currentTimeMillis() > expireTime) {
iterator.remove();
expireTimeMap.remove(entry.getKey());
}
}
}
}
}).start();
}
}
/**
* key是否存在
* @param key
* @return
*/
public static boolean isExist(String key) {
return cacheMap.containsKey(key);
}
public static void main(String[] args) {
EasyCacheUtil.set("testKey_1", "testValue_1");
EasyCacheUtil.set("testKey_2", "testValue_2", 1);
EasyCacheUtil.set("testKey_3", "testValue_3");
EasyCacheUtil.set("testKey_4", "testValue_4", 1);
Object testKey_2 = EasyCacheUtil.get("testKey_2");
System.out.println(testKey_2);
}
}