3.0的DUX完善了自定义模型和筛选模型,负载能力也比2.0有很大提升

so刚出测试版就搭建了一个站点用以测试

在使用中发现了一些细节的问题

1、列表顺序

比方说列表页排列顺序和点击筛选后顺序是正序的,这个需要修改

 /app/article/controller/IndexController.php

$classIds = target('article/ArticleClass')->getSubClassId($classId);
        $where['_sql'] = 'B.class_id in (' . $classIds . ') ORDER BY B.content_id desc';
 
        $attrList = [];
        if($classInfo['filter_id']) {
            $filter = target('site/SiteFilter')->getFilter('article/ArticleClass', $classIds, ['id' => $classId]);
            if ($filter['status']) {
                $where['_sql'] = 'A.content_id in (' . $filter['ids'] . ') ORDER BY B.content_id desc';
            }
            $attrList = $filter['attrList'];
        }

大约36,42行的位置加入ORDER BY B.content_id desc,可以在不影响响应速度的前提下把顺序改为倒序。

2、内页响应时间

/*
        target('site/SiteContent')->where(['content_id' => $info['content_id']])->setInc('view');

        $where = [];
        $where['A.status'] = 1;
        $where['_sql'] = 'A.create_time < ' . $info['create_time'];
        $where['B.class_id'] = $info['class_id'];
        $nextInfo = target('article/Article')->loadList($where, 1);

        $where = [];
        $where['A.status'] = 1;
        $where['_sql'] = 'A.create_time > ' . $info['create_time'];
        $where['B.class_id'] = $info['class_id'];
        $prevInfo = target('article/Article')->loadList($where, 1);*////这里注释用以减少sql查询

/app/article/controller/InfoController.php

注释掉大约62-75行之间的代码,可以极大的提升内页响应时间,3W数据内页响应时间从2S缩短到0.02S

标签: none

添加新评论