自定义缓存的触发器在哪里

自定义缓存的触发器在哪里

本文介绍了Magento:自定义缓存的触发器在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这个Stackoverflow问题中,答案显示了如何添加自定义缓存状态: Magento自定义使用管理开关缓存

In this Stackoverflow question the answer shows how to add a custom cache status: Magento Custom Caching with admin switch

现在我的问题是:这是在哪里触发的?

Now my question is: Where is this triggered?

更新:我已按照上述步骤进行操作.现在,我在Abstract/Service.php

UPDATE:I've followed the steps as mentioned above. Now I have this code in Abstract/Service.php

final class COMP_NAME_Abstract_Service
{

    static private $_instance;
    private $_licenseHelpers = array();

    public function clearCache( $custom = false )
    {
        //DO SOMETHING
    }

    public function getCache()
    {
        //DO SOMETHING
    }
}

但是我必须在某个地方调用" clearCache函数,但是在哪里以及如何?

But I have to 'call' the clearCache function somewhere, but where and how?

推荐答案

您可以使用事件adminhtml_cache_refresh_type.全局添加到事件部分.

You can use event adminhtml_cache_refresh_type.Add to event section in global.

<global>
  <events>
    <adminhtml_cache_refresh_type>
    <observers>
        <module_alias>
            <class>COMPNAME_MODULENAME_Model_Observer</class>
            <type>singleton</type>
            <method>cleanCacheType</method>
        </module_alias>
     </observers>
     </adminhtml_cache_refresh_type>
   </events>
</global>

将此代码添加到观察者COMP_NAME_module_name_Model_Observer:

Add this code to observer COMP_NAME_module_name_Model_Observer:

public function cleanCacheType(Varien_Event_Observer $observer)
{
   if ($observer->getData('type') == "your_cache_type"){
       //CUSTOM CODE
   }
}

这篇关于Magento:自定义缓存的触发器在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 09:37