/** * @see ICache::get() */ public function get($key, $expire = null) { if ($expire !== null) { $this->configs['expire'] = $expire; } $cacheFile = $this->getCacheFile($key); //缓存文件不存在 if (!file_exists($cacheFile)) { if (APP_DEBUG) { Debug::appendMessage("缓存文件 {$cacheFile} 不存在."); } return false; } //缓存过期, 若$expire = 0 则表示缓存永不过期 if ($this->configs['expire'] > 0 && time() > filemtime($cacheFile) + $this->configs['expire']) { if (APP_DEBUG) { Debug::appendMessage("缓存文件 {$cacheFile} 已经过期."); } return false; } else { $content = file_get_contents($cacheFile); if (ArrayUtils::isSerializedArray($content)) { return unserialize($content); } else { return $content; } } }