/** * Save data * * @param string $data * @param string $id * @param array $tags * @param int $lifeTime * @return bool */ public function save($data, $id, $tags = array(), $lifeTime = null) { if (!in_array(self::CACHE_TAG, $tags)) { $tags[] = self::CACHE_TAG; } if (is_null($lifeTime)) { $lifeTime = (int) $this->getFrontend()->getOption('lifetime'); } // edit cached object $cacheData = new Varien_Object(); $cacheData->setCachedata($data); $cacheData->setCacheId($id); $cacheData->setTags($tags); $cacheData->setLifeTime($lifeTime); Mage::dispatchEvent('fpc_save_data_before', array('cache_data' => $cacheData)); $data = $cacheData->getCachedata(); $id = $cacheData->getCacheId(); $tags = $cacheData->getTags(); $lifeTime = $cacheData->getLifeTime(); $compressLevel = Mage::getStoreConfig(self::GZCOMPRESS_LEVEL_XML_PATH); if ($compressLevel != -2) { $data = gzcompress($data, $compressLevel); } return $this->_frontend->save($data, $this->_id($id), $this->_tags($tags), $lifeTime); }
/** * This method will dispatch the event 'jv_cache_save_block' when cache is saved for a html block. * * {@inheritdoc} */ public function save($data, $id, $tags = array(), $specificLifetime = false) { if (in_array($this->getFrontendPrefix() . 'BLOCK_HTML', $tags)) { $transportObject = new Varien_Object(); /** @noinspection PhpUndefinedMethodInspection */ $transportObject->setTags($tags); Mage::dispatchEvent('jv_cache_save_block', array('id' => $id, 'transport' => $transportObject)); /** @noinspection PhpUndefinedMethodInspection */ $tags = $transportObject->getTags(); } return parent::save($data, $id, $tags, $specificLifetime); }
/** * This method will dispatch the event 'jv_clean_backend_cache'. * Event listeners can change the mode or tags. * * {@inheritdoc} */ public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) { $transportObject = new Varien_Object(); /** @noinspection PhpUndefinedMethodInspection */ $transportObject->setMode($mode); /** @noinspection PhpUndefinedMethodInspection */ $transportObject->setTags($tags); Mage::dispatchEvent('jv_clean_backend_cache', array('transport' => $transportObject)); /** @noinspection PhpUndefinedMethodInspection */ $mode = $transportObject->getMode(); /** @noinspection PhpUndefinedMethodInspection */ $tags = $transportObject->getTags(); return parent::clean($mode, $tags); }
/** * This method will dispatch the events 'magehost_clean_backend_cache_before' * and 'magehost_clean_backend_cache_after'. * Event listeners can change the mode or tags. * This method will return false when clean failed. * * {@inheritdoc} */ public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) { $result = false; $transportObject = new Varien_Object(); /** @noinspection PhpUndefinedMethodInspection */ $transportObject->setMode($mode); /** @noinspection PhpUndefinedMethodInspection */ $transportObject->setTags($tags); Mage::dispatchEvent('jv_clean_backend_cache', array('transport' => $transportObject)); // deprecated Mage::dispatchEvent('magehost_clean_backend_cache_before', array('transport' => $transportObject)); /** @noinspection PhpUndefinedMethodInspection */ $mode = $transportObject->getMode(); /** @noinspection PhpUndefinedMethodInspection */ $tags = $transportObject->getTags(); if ($this->works) { try { $result = parent::clean($mode, $tags); } catch (CredisException $e) { $this->processRedisException($e, 'remove'); $result = false; } catch (RedisException $e) { $this->processRedisException($e, 'remove'); $result = false; } catch (Zend_Cache_Exception $e) { $this->processRedisException($e, 'remove'); $result = false; } } $transportObject->setResult($result); Mage::dispatchEvent('magehost_clean_backend_cache_after', array('transport' => $transportObject)); $result = $transportObject->getResult(); return $result; }