Exemplo n.º 1
0
 public static function getInstance()
 {
     if (self::$_instance == null) {
         self::$_instance = new self();
     }
     self::$_instance->setCacheSaveFile(TEMP_PATH . '/Cache/Data');
     return self::$_instance;
 }
Exemplo n.º 2
0
 /**
  * 缓存数据库字段信息
  * @access	private
  * @return	array 字段列表
  */
 private function _makeCacheTableFields()
 {
     $cache_key = md5($this->_db_name . $this->_table_name);
     $cache = XF_Cache_SECache::getInstance();
     if (!is_dir(TEMP_PATH . '/Cache/')) {
         XF_File::mkdirs(TEMP_PATH . '/Cache/');
     }
     $cache->setCacheSaveFile(TEMP_PATH . '/Cache/DatabaseField');
     $content = $cache->read($cache_key);
     if ($content !== XF_CACHE_EMPTY) {
         return $content;
     }
     //缓存字段
     $tmp = $this->getTableSelect()->getFields();
     $cache->setCacheTime(60 * 24 * 30)->add($cache_key, $tmp);
     return $tmp;
 }
Exemplo n.º 3
0
 /**
  * 检测是否存在缓存文件
  * @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;
 }