|
|
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 编辑 ] |
|