destoon采集论坛

 找回密码
 立即注册
查看: 29|回复: 0

如何设置让缓存能如下工作---在线等---标题要长

[复制链接]

3

主题

0

回帖

13

积分

新手上路

Rank: 1

积分
13
发表于 2012-4-1 12:44:56 | 显示全部楼层 |阅读模式
DT4貌似纪录(比如产品或者公司纪录)和模板分别做了缓存,我想把模板缓存关掉,但纪录缓存继续工作。每次请求纪录时,如果纪录有缓存,那么就输出缓存,不管模板是否更新;如果纪录没有缓存,那么读取数据库,读取并编译模板(而不是模板缓存)。

尝试修改function template
function template($template = 'index', $dir = '') {
        global $CFG;
        $to = $dir ? DT_CACHE.'/tpl/'.$dir.'-'.$template.'.php' : DT_CACHE.'/tpl/'.$template.'.php';
        if($CFG['template_refresh'] || !is_file($to)) {
                if($dir) $dir = $dir.'/';
        $from = DT_ROOT.'/template/'.$CFG['template'].'/'.$dir.$template.'.htm';
                if($CFG['template'] != 'default' && !is_file($from)) {
                        $from = DT_ROOT.'/template/default/'.$dir.$template.'.htm';
                }
        if(!is_file($to) || filemtime($from) > filemtime($to)) {
                        require_once DT_ROOT.'/include/template.func.php';
                        template_compile($from, $to);
                }
        }
        return $to;
}
改为
function template($template = 'index', $dir = '') {
        global $CFG;
        $to = $dir ? DT_CACHE.'/tpl/'.$dir.'-'.$template.'.php' : DT_CACHE.'/tpl/'.$template.'.php';
        if($CFG['template_refresh'] || !is_file($to)) {
                if($dir) $dir = $dir.'/';
        $from = DT_ROOT.'/template/'.$CFG['template'].'/'.$dir.$template.'.htm';
                if($CFG['template'] != 'default' && !is_file($from)) {
                        $from = DT_ROOT.'/template/default/'.$dir.$template.'.htm';
                }
        require_once DT_ROOT.'/include/template.func.php';
        template_compile($from, $to);
        }
        return $to;
}

这样让程序不每次都读取编译模板。改后发现,每次读取同一条纪录,都调用了模板读取编译动作,而不是读的纪录缓存。貌似DT4逻辑是,模板改了,读取纪录就要更新缓存。怎么修改实现,读取记录时,与模板修改与否无关了?纪录有缓存就输出缓存,没缓存才调用模板并编译?否则系统负载我想会很大。求大侠指点

[ 本帖最后由 algous2002 于 2012-4-1 12:50 编辑 ]
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|destoon采集论坛

GMT+8, 2025-11-26 13:13 , Processed in 0.018560 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表