PHP群:95885625 Hbuilder+MUI群:81989597 站长QQ:634381967
    您现在的位置: 首页 > CMS教程 > phpcms教程 > 正文

    如何 提高v9的缓存加载速度?

    作者:admin来源:网络浏览:时间:2020-09-30 00:07:50我要评论
    导读:修改了 cache_file.class.php 的get方法,主要是防止同一页面多次加载同一个缓存文件造成的效率低下.另外提醒一点,文件缓存如果采用serial...
    修改了 cache_file.class.php 的get方法,主要是防止同一页面多次加载同一个缓存文件造成的效率低下.
    另外提醒一点,文件缓存如果采用serialize方式,能提高1/3的读取速度.‘
     
    复制代码 代码如下:
            public function get($name, $setting = '', $type = 'data', $module = ROUTE_M) {
                    $this->get_setting($setting);
                    if(empty($type)) $type = 'data';
                    if(empty($module)) $module = ROUTE_M;
                    $filepath = CACHE_PATH.'caches_'.$module.'/caches_'.$type.'/';
                    $filename = $name.$this->_setting['suf'];
                    //add 防止重复加载
            static $datas;
                    $markid = md5($filepath.$filename);
                    if($datas[$markid]) return $datas[$markid];
                    //end
                    if (!file_exists($filepath.$filename)) {
                            return false;
                    } else {
                        if($this->_setting['type'] == 'array') {
                                $data = @require($filepath.$filename);
                        } elseif($this->_setting['type'] == 'serialize') {
                                $data = unserialize(file_get_contents($filepath.$filename));
                        }
                        //add
                            $datas[$markid] = $data;
                            //end
                        return $data;
                    }
            }
    转载请注明(B5教程网)原文链接:https://b5.mxunkeji.com/content-101-581-1.html
    相关热词搜索: phpcms v9 缓存