// 载入缓存信息 public static void putCacheInfo(String key, Cache obj, long dt, boolean expired) { Cache cache = new Cache(); cache.setKey(key); cache.setTimeOut(dt + System.currentTimeMillis()); // 设置多久后更新缓存 cache.setValue(obj); cache.setExpired(expired); // 缓存默认载入时,终止状态为FALSE cacheMap.put(key, cache); }
// 重写载入缓存信息方法 public static void putCacheInfo(String key, Cache obj, long dt) { Cache cache = new Cache(); cache.setKey(key); cache.setTimeOut(dt + System.currentTimeMillis()); cache.setValue(obj); cache.setExpired(false); cacheMap.put(key, cache); }
// 获取缓存信息 public static Cache getCacheInfo(String key) { if (hasCache(key)) { Cache cache = getCache(key); if (cacheExpired(cache)) { // 调用判断是否终止方法 cache.setExpired(true); } return cache; } else return null; }