我在symfony2中使用Doctrine结果缓存。
只有在生产环境学说中,结果缓存删除不是删除缓存。但在开发环境中,结果缓存删除可以正常工作。
这是我编写的在条令中使用结果缓存的代码。
//code to store result cache in doctrin.
$qb->useResultCache(true);
$qb->setResultCacheId('key');
//code to delete result cache when db data edit.
$em->getConfiguration()->getResultCacheImpl()->delete('key');
这里的问题是symfony2中的生产环境。
生产环境是否有任何特殊的条令缓存配置?
请帮我解决这个问题。
它不应该是生产环境的任何特殊标志。Doctrine甚至不关心环境,尤其是在初始化内核时设置的Symfony2内容,例如:
#web/app.php
...
$kernel = new AppKernel('prod', false);
也许第一次检查:
echo $this->container->get('kernel')->getEnvironment();
100%确定自己处于"刺激"环境中。
如果你是,你可以试试:
$em->getConfiguration()->getResultCacheImpl()->deleteAll();
检查它是否会删除环境的所有缓存,这样你就会知道这是delete("key")方法的特定问题还是其他问题。