【问题标题】:Magento "Flush Cache Storage"Magento“刷新缓存存储”
【发布时间】:2013-02-22 15:58:56
【问题描述】:

我了解 Magento (example) 中“刷新 Magento 缓存”和“刷新缓存存储”之间的区别。我正在尝试执行一项会不时刷新缓存存储的 cron 作业。

我假设这个按钮不只是删除 var/cache/ 的内容,但我找不到一个可靠的资源来说明它的作用。我正在使用 APC 以及所有内置的 Magento 缓存功能。

是否可以从脚本中运行相当于“Fluch Cache Storage”按钮的功能?

【问题讨论】:

    标签: magento caching cron storage flush


    【解决方案1】:

    app/code/core/Mage/Adminhtml/controllers/CacheController.php中可以看到flushAllAction()(点击Flush Cache Storage时调用的动作)被调用。

    此函数包含以下内容:

    /**
     * Flush cache storage
     */
    public function flushAllAction()
    {
        Mage::dispatchEvent('adminhtml_cache_flush_all');
        Mage::app()->getCacheInstance()->flush();
        $this->_getSession()->addSuccess(Mage::helper('adminhtml')->__("The cache storage has been flushed."));
        $this->_redirect('*/*');
    }
    

    要在您自己的文件中调用它,您可以执行以下操作。

    require_once('app/Mage.php');
    Mage::app()->getCacheInstance()->flush();
    

    现在,您可以使用 cronjob 运行您的 php 文件。

    【讨论】:

      【解决方案2】:

      here 你可以找到关于“Flush Cache Storage”和“Flush Magento Cache”之间区别的很好的解释。

      我同意您应该使用以下方法创建 CRON TASK(如果确实需要清理缓存)(how to):

      public function flushAllAction()
      {
          // Additional code if necessary
          Mage::app()->getCacheInstance()->flush();
          // Additional code if necessary
      }
      

      如果您需要进一步的帮助,请不要犹豫。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-12-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-04-30
        • 1970-01-01
        • 2015-03-22
        相关资源
        最近更新 更多