Exemplo n.º 1
0
 public function clean($tags = array())
 {
     $start = microtime(true) * 1000;
     $res = parent::clean($tags);
     $this->appendLog(self::TYPE_CLEAN, implode(';', $tags), round(microtime(true) * 1000 - $start));
     return $res;
 }
Exemplo n.º 2
0
 /**
  * Clear request path cache by tag
  * (used for redirects invalidation)
  *
  * @param Varien_Event_Observer $observer
  * @return $this
  */
 public function clearRequestCacheByTag(Varien_Event_Observer $observer)
 {
     if (!$this->isCacheEnabled()) {
         return $this;
     }
     $redirect = $observer->getEvent()->getRedirect();
     $this->_cacheInstance->clean(array(Enterprise_PageCache_Helper_Url::prepareRequestPathTag($redirect->getData('identifier')), Enterprise_PageCache_Helper_Url::prepareRequestPathTag($redirect->getData('target_path')), Enterprise_PageCache_Helper_Url::prepareRequestPathTag($redirect->getOrigData('identifier')), Enterprise_PageCache_Helper_Url::prepareRequestPathTag($redirect->getOrigData('target_path'))));
     return $this;
 }
Exemplo n.º 3
0
 /**
  * @dataProvider cleanDataProvider
  */
 public function testClean(array $cacheData, array $cleanCacheTags, array $expectedCacheIds)
 {
     /* Fill cache with predefined tagged data */
     foreach ($cacheData as $cacheId => $cacheTags) {
         $this->_model->save("data_for_{$cacheId}", $cacheId, $cacheTags);
     }
     /* Clean cache by tags */
     $this->_model->clean($cleanCacheTags);
     /* Check removed data */
     foreach (array_keys($cacheData) as $cacheId) {
         $cacheData = $this->_model->load($cacheId);
         if (in_array($cacheId, $expectedCacheIds)) {
             $this->assertNotEmpty($cacheData);
         } else {
             $this->assertFalse($cacheData);
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Cleaning cache
  *
  * @param   array $tags
  * @return  Mage_Core_Model_App
  */
 public function cleanCache($tags = array())
 {
     $this->_cache->clean($tags);
     Mage::dispatchEvent('application_clean_cache', array('tags' => $tags));
     return $this;
 }
Exemplo n.º 5
0
 public function testCleanByConfig()
 {
     $this->_cacheFrontend->expects($this->at(0))->method('clean')->with(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array(Mage_Core_Model_App::CACHE_TAG))->will($this->returnValue(true));
     $this->_cacheFrontend->expects($this->at(1))->method('clean')->with(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array(Mage_Core_Model_Config::CACHE_TAG))->will($this->returnValue(true));
     $this->_model->clean();
 }
Exemplo n.º 6
0
 /**
  * Remove model onject related cache
  *
  * @return Mage_Core_Model_Abstract
  */
 public function cleanModelCache()
 {
     $tags = $this->getCacheTags();
     if ($tags !== false) {
         $this->_cacheManager->clean($tags);
     }
     return $this;
 }