/** * 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; }
/** * Saves informational cache, containing parameters used to show lists. * * @return Ves_Optimize_Model_Container_CatalogProductItem */ protected function _saveInfoCache() { $placeholderName = $this->_placeholder->getName(); if (is_null(self::$_sharedInfoData[$placeholderName]['info'])) { return $this; } $data = array(); $cacheRecord = Ves_Optimize_Model_Container_Abstract::_loadCache($this->_getCacheId()); if ($cacheRecord) { $cacheRecord = json_decode($cacheRecord, true); if ($cacheRecord) { $data = $cacheRecord; } } $data[$this->_getInfoCacheId()] = self::$_sharedInfoData[$placeholderName]['info']; $data = json_encode($data); $tags = array(Ves_Optimize_Model_Processor::CACHE_TAG); $lifetime = $this->_placeholder->getAttribute('cache_lifetime'); if (!$lifetime) { $lifetime = false; } Ves_Optimize_Model_Cache::getCacheInstance()->save($data, $this->_getCacheId(), $tags, $lifetime); return $this; }