示例#1
0
文件: Abstract.php 项目: kevinwan/xf
 /**
  * 获取数据缓存
  * @access protected
  * @param array $result
  */
 protected function _getDataCache($file = null)
 {
     $content = XF_CACHE_EMPTY;
     if ($file == null) {
         $file = $this->_getDataCacheFileName();
     }
     if ($this->_cache_class instanceof XF_Cache_Interface) {
         $content = $this->_cache_class->read($file);
     }
     //如果正常缓存为NULL,再检测当前临时缓存
     if ($content == XF_CACHE_EMPTY) {
         $content = XF_DataPool::getInstance()->getHash('TEMP_DATA_CACHE', md5($file), XF_CACHE_EMPTY);
     }
     return $content;
 }
示例#2
0
文件: Abstract.php 项目: kevinwan/xf
 /**
  * 检测是否存在缓存文件
  * @access private
  * @return void
  */
 private function _checkCacheContent()
 {
     $key = $this->getCacheSign();
     if ($key == '') {
         return;
     }
     //如果没有设置缓存类型,则默认为secache
     if ($this->_cache_instance == null) {
         $this->_cache_instance = XF_Cache_SECache::getInstance();
     }
     if ($this->_cache_instance instanceof XF_Cache_SECache) {
         $cache_file = TEMP_PATH . '/Cache/ActionViewCache';
         if (!is_file($cache_file . '.php')) {
             return null;
         }
         $this->_cache_instance->setCacheSaveFile($cache_file);
     }
     //是否存强制清除缓存
     if (XF_DataPool::getInstance()->get('clearActionCache') === true) {
         $this->_cache_instance->remove($key);
         return null;
     }
     $content = $this->_cache_instance->read($key);
     if ($content == XF_CACHE_EMPTY) {
         return null;
     }
     //检测布局
     preg_match('/<!--Layout:(.*?)-->/', $content, $matches);
     if (isset($matches[0])) {
         $tmp = explode(',', $matches[1]);
         $layoutName = $tmp[0];
         $layout = new $layoutName();
         $layout->setCacheTime($tmp[1]);
         $layout->setCacheType($tmp[2]);
         //清除布局标记
         $content = str_replace($matches[0], '', $content);
         //执行布局对象,并渲染布局模板
         if ($layout instanceof XF_View_Layout_Abstract) {
             //获取缓存的标题等信息
             $this->_checkCacheHtmlTag($content);
             $layout->assign('$layoutContent', $content);
             $content = $layout->render();
         }
     }
     return $content;
 }