Exemple #1
0
 /**
  * Save data to cache storage. Store many block instances in one cache record depending on additional cache ids.
  *
  * @param string $data
  * @param string $id
  * @param array $tags
  * @param null|int $lifetime
  * @return Ves_Optimize_Model_Container_Advanced_Abstract
  */
 protected function _saveCache($data, $id, $tags = array(), $lifetime = null)
 {
     $additionalCacheId = $this->_getAdditionalCacheId();
     if (!$additionalCacheId) {
         Mage::throwException(Mage::helper('ves_optimize')->__('Additional id should not be empty'));
     }
     $tags[] = Ves_Optimize_Model_Processor::CACHE_TAG;
     $tags = array_merge($tags, $this->_getPlaceHolderBlock()->getCacheTags());
     if (is_null($lifetime)) {
         $lifetime = $this->_placeholder->getAttribute('cache_lifetime') ? $this->_placeholder->getAttribute('cache_lifetime') : false;
     }
     Ves_Optimize_Helper_Data::prepareContentPlaceholders($data);
     $result = array();
     $cacheRecord = parent::_loadCache($id);
     if ($cacheRecord) {
         $cacheRecord = json_decode($cacheRecord, true);
         if ($cacheRecord) {
             $result = $cacheRecord;
         }
     }
     $result[$additionalCacheId] = $data;
     Ves_Optimize_Model_Cache::getCacheInstance()->save(json_encode($result), $id, $tags, $lifetime);
     return $this;
 }
Exemple #2
0
 /**
  * Save data to cache storage
  *
  * @param string $data
  * @param string $id
  * @param array $tags
  * @param null|int $lifetime
  * @return Ves_Optimize_Model_Container_Abstract
  */
 protected function _saveCache($data, $id, $tags = array(), $lifetime = null)
 {
     $tags[] = Ves_Optimize_Model_Processor::CACHE_TAG;
     $tags = array_merge($tags, $this->_getPlaceHolderBlock()->getCacheTags());
     if (is_null($lifetime)) {
         $lifetime = $this->_placeholder->getAttribute('cache_lifetime') ? $this->_placeholder->getAttribute('cache_lifetime') : false;
     }
     Ves_Optimize_Helper_Data::prepareContentPlaceholders($data);
     Ves_Optimize_Model_Cache::getCacheInstance()->save($data, $id, $tags, $lifetime);
     return $this;
 }