[英]Zend\Cache\Storage\Adapter clearByTags Tag with parameters in ZF2
I'm using bramstroker's StrokerCache Zend Framework 2 module which itself uses Zend\\Cache and has the method clearByTags() . 我正在使用bramstroker的StrokerCache Zend Framework 2模块,该模块本身使用Zend \\ Cache并具有方法clearByTags() 。
If I want to clear cache, th following works fine: 如果我想清除缓存,则可以正常工作:
public function fooAction()
{
$cs = $this->getServiceLocator()->get('strokercache_service');
var_dump($cs->clearByTags(array(
'controller_ClientCms\Controller\Cms'
)));
}
However, what if I want to include parameters? 但是,如果要包含参数怎么办?
$cs->clearByTags(array(
'controller_ClientCms\Controller\Cms,param_action:index,param_client:foo'
));
...does not work. ... 不起作用 。
Here is how the tag-file in the cache directory looks like: 缓存目录中的标记文件如下所示:
strokercache_route_home/client
strokercache_controller_ClientCms\Controller\Cms
strokercache_param_action_index
strokercache_param_client_foo
The answare is simple: Please use ever tag as an own array element: Answare很简单:请使用ever标签作为自己的数组元素:
$cs->clearByTags(array(
'controller_ClientCms\Controller\Cms',
'param_action_index',
'param_client_foo',
));
As I don't use the module I can't test it but after a quick code review this should work. 由于我不使用该模块,因此无法对其进行测试,但是在快速检查代码后,此方法应该可以工作。 see https://github.com/bramstroker/zf2-fullpage-cache/blob/master/src/StrokerCache/Controller/CacheController.php#L41
参见https://github.com/bramstroker/zf2-fullpage-cache/blob/master/src/StrokerCache/Controller/CacheController.php#L41
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.