我正在使用新的Symfony缓存组件。我第一次产生我的缓存的命令(指令/ AppCacheGenerateCommand.php):Symfony缓存组件(3.1)不保存缓存
$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(事件监听/ RequestListener.php)这些缓存的元素
$cache = new FileSystemAdapter();
$domainCache = $cache->getItem('domain.' . $host);
if (!$domainCache->isHit()){
die;
}
它总是在这里死亡,而不是进一步。任何人都可以给我一个解释? (我试过,如果主机不匹配,但它确实...)
你必须在解决方案中添加一个答案(然后接受它),而不是在你的问题中更新。查看帮助中心! –