/**
* @return void
*/
function __construct()
{
$ok = false;
if ($this->factory->getConfFile() === null) {
$key = 'phprs_route3_' . sha1(serialize($this->factory->getConf()));
} else {
$key = 'phprs_route3_' . sha1($this->factory->getConfFile());
}
$this->impl = $this->cache->get($key, $ok);
if ($ok && is_object($this->impl)) {
Logger::info("router loaded from cache");
return;
}
$this->impl = $this->factory->create('phprs\\Router');
//缓存过期判断依据
//检查接口文件是否有修改\新增
$check_files = array_values($this->impl->getApiFiles());
$check_dirs = array();
foreach ($check_files as $file) {
if (is_file($file)) {
$check_dirs[] = dirname($file);
}
}
$check_files = array_merge($check_files, $check_dirs);
$check_files[] = $this->factory->getConfFile();
$this->cache->set($key, $this->impl, 0, new FileExpiredChecker($check_files));
//接口文件或者配置文件修改
}