簡體   English   中英

Zend \\ Cache \\ Storage \\ Adapter clearByTags帶有ZF2中參數的標簽

[英]Zend\Cache\Storage\Adapter clearByTags Tag with parameters in ZF2

我正在使用bramstroker的StrokerCache Zend Framework 2模塊,該模塊本身使用Zend \\ Cache並具有方法clearByTags()

如果我想清除緩存,則可以正常工作:

public function fooAction()
{
    $cs = $this->getServiceLocator()->get('strokercache_service');
    var_dump($cs->clearByTags(array(
        'controller_ClientCms\Controller\Cms'           
    )));
}

但是,如果要包含參數怎么辦?

    $cs->clearByTags(array(
        'controller_ClientCms\Controller\Cms,param_action:index,param_client:foo'           
    ));

... 不起作用

緩存目錄中的標記文件如下所示:

strokercache_route_home/client
strokercache_controller_ClientCms\Controller\Cms
strokercache_param_action_index
strokercache_param_client_foo

Answare很簡單:請使用ever標簽作為自己的數組元素:

$cs->clearByTags(array(
    'controller_ClientCms\Controller\Cms',
    'param_action_index',
    'param_client_foo',
));

由於我不使用該模塊,因此無法對其進行測試,但是在快速檢查代碼后,此方法應該可以工作。 參見https://github.com/bramstroker/zf2-fullpage-cache/blob/master/src/StrokerCache/Controller/CacheController.php#L41

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM