Magento "Flush Cache Storage"

8
我了解Magento中“Flush Magento Cache”和“Flush Cache Storage”的区别(示例)。我正在尝试创建一个定时任务,定期清空缓存存储。
我假设这个按钮不仅仅是删除var/cache/目录下的内容,但我找不到确切的资源来说明它的作用。我使用APC以及所有内置的Magento缓存功能。
是否可能从脚本中运行等效于“Fluch Cache Storage”按钮的操作?
2个回答

11
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文件。

3
这里,你可以找到关于“Flush Cache Storage”和“Flush Magento Cache”的区别的好解释。
我认为如果清理缓存确实有必要,应该创建CRON任务(如何设置)使用以下方法:
public function flushAllAction()
{
    // Additional code if necessary
    Mage::app()->getCacheInstance()->flush();
    // Additional code if necessary
}

如果您需要更多帮助,请不要犹豫,直接提出来。此文涉及IT技术,请您留意。请注意,保留了HTML标签。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接