2013-02-22 108 views
7

我明白了「同花順的Magento緩存」和「清除緩存存儲」之間在Magento(example)的差異。我正在嘗試使用cron作業來刷新緩存存儲。Magento的「清除緩存存儲」

我假設,這個按鈕不只是刪除VAR /緩存/的內容,但我找不到,說什麼它做了堅實的資源。我正在使用APC以及所有內置的Magento緩存功能。

是否可以運行「Fluch緩存存儲」按鈕,從腳本相同呢?

回答

10

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

here你可以找到關於「清除緩存存儲」和「刷新Magento的緩存」之間的區別很好的解釋。

我同意,你應該有方法來創建定期任務(如果幹淨的緩存是真的有必要)(how to):

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

如果您需要進一步的幫助,請不要猶豫,問。