我正在使用新的 Symfony 缓存组件。我首先使用命令 (Command/AppCacheGenerateCommand.php) 生成缓存:
$cache = new FilesystemAdapter();
foreach ($domains as $domain){
if ($domain->getHost()){
$output->writeln('Generate cache for domain: ' . $domain->getHost());
$domainCache = $cache->getItem('domain.' . $domain->getHost());
$domainCache->set($domain->getId());
$cache->save($domainCache);
}
}
然后尝试在 onKernelRequest EventListener (EventListener/RequestListener.php) 中获取这些缓存的元素
$cache = new FileSystemAdapter();
$domainCache = $cache->getItem('domain.' . $host);
if (!$domainCache->isHit()){
die;
}
它总是死在这里,不会更进一步。谁能给我一个解释?(我试过如果主机不匹配,但它确实......)