Ejemplo n.º 1
0
 /**
  * 构造函数
  *
  * @param string $type          采用哪种类型加速{file:文件类型 mem:Memcached}
  * @param int    $expire        加速数据有效期(单位分钟)默认为0是为了采用全局设置的有效期
  * @param string $puid          缓冲时的唯一编号
  * @param string $floder        如果type=file生效,缓冲在哪个目录当中
  * @param string $ext           如果type=file生效,生成哪个类型的文件
  */
 public function __construct($type = 'file', $expire = 0, $puid = '', $floder = '', $ext = '.html')
 {
     /**
      * 判断是否启动加速服务,当有POST数据时则不加速内容或者是否设定了启动加速内容常量且为真
      */
     if (!empty($_POST) || defined('SPEED_DATA') && !SPEED_DATA) {
         return;
     }
     /**
      * 初始化相关数据
      */
     $this->_ext = empty($ext) ? $this->_ext : $ext;
     $this->_type = strtolower($type) == 'mem' ? 'mem' : 'file';
     $this->_floder = empty($floder) ? $_SERVER['DOCUMENT_ROOT'] : $floder;
     $expire = intval($expire);
     //加速数据有效期(单位分钟)
     $this->_expire = $expire > 0 ? $expire : (defined('SPEED_DATA_EXPIRE') ? SPEED_DATA_EXPIRE : 10);
     /**
      * 缓冲时的唯一编号
      */
     if (!empty($puid)) {
         $this->_puid = $puid;
     } else {
         $this->generate_puid();
         //生成页面唯一页面编号
     }
     /**
      * 判断采用哪种媒介存储,如果是采用MEM就创建MEM对象
      */
     if ($this->_type == 'mem') {
         $this->_mem = wcore_object::mem();
     }
 }
Ejemplo n.º 2
0
 /**
  * 打开 SESSION
  *
  * @param string $path 会话存储路径
  * @param string $name 会话名称
  * @return boolean
  */
 public function open($path, $name)
 {
     if ($this->_type == 'db' || $this->_type == 'mdb') {
         $this->_db = wcore_object::mdb();
         if ($this->_type == 'mdb') {
             $this->_opt = 'session_mem';
         }
     } else {
         if ($this->_type == 'mem') {
             $this->_mem = wcore_object::mem();
             $this->_mem->expire = $this->_life_time / 60;
         }
     }
     $this->gc(0);
     //删除失效的SESSION
     return true;
 }