mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-01 08:12:17 +09:00
#18885392 Optimizer Template 에 Cache적용
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@7451 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
f07cc09e4f
commit
96b197c3a5
4 changed files with 232 additions and 152 deletions
|
|
@ -60,16 +60,25 @@
|
|||
if(!count($targets)) return $this->_getOptimizedRemoved($files);
|
||||
|
||||
$list_file_hash = md5($hash);
|
||||
$list_file = FileHandler::getRealPath($this->cache_path . $list_file_hash);
|
||||
$oCacheHandler = &CacheHandler::getInstance('template');
|
||||
if($oCacheHandler->isSupport()){
|
||||
if(!$oCacheHandler->isValid($list_file_hash)){
|
||||
$buff = array();
|
||||
foreach($targets as $file) $buff[] = $file['file'];
|
||||
$oCacheHandler->put($list_file_hash, $buff);
|
||||
}
|
||||
}else{
|
||||
$list_file = FileHandler::getRealPath($this->cache_path . $list_file_hash);
|
||||
|
||||
if(!file_exists($list_file)){
|
||||
$str = '<?php $f=array();';
|
||||
foreach($targets as $file) $str .= '$f[]="'. $file['file'] . '";';
|
||||
$str .= ' return $f; ?>';
|
||||
|
||||
FileHandler::writeFile($list_file, $str);
|
||||
if(!file_exists($list_file)){
|
||||
$str = '<?php $f=array();';
|
||||
foreach($targets as $file) $str .= '$f[]="'. $file['file'] . '";';
|
||||
$str .= ' return $f; ?>';
|
||||
|
||||
FileHandler::writeFile($list_file, $str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
array_unshift($files, array('file' => sprintf($this->script_file, $list_file_hash, $type) , 'media' => 'all'));
|
||||
$files = $this->_getOptimizedRemoved($files);
|
||||
if(!count($files)) return $files;
|
||||
|
|
|
|||
|
|
@ -55,14 +55,25 @@
|
|||
$this->tpl_path = preg_replace('/^\.\//','',$tpl_path);
|
||||
$this->tpl_file = $tpl_file;
|
||||
|
||||
// get cached compiled file name
|
||||
$compiled_tpl_file = FileHandler::getRealPath($this->_getCompiledFileName($tpl_file));
|
||||
$oCacheHandler = &CacheHandler::getInstance('template');
|
||||
if($oCacheHandler->isSupport()){
|
||||
$buff = $oCacheHandler->get('template:'.$tpl_file, filemtime(FileHandler::getRealPath($tpl_file)));
|
||||
if(!$buff){
|
||||
$buff = $this->_compileTplFile($tpl_file);
|
||||
$oCacheHandler->put('template:'.$tpl_file, $buff);
|
||||
}
|
||||
|
||||
// compile
|
||||
$buff = $this->_compile($tpl_file, $compiled_tpl_file);
|
||||
$output = $this->_fetch('', $buff, $tpl_path);
|
||||
}else{
|
||||
// get cached compiled file name
|
||||
$compiled_tpl_file = FileHandler::getRealPath($this->_getCompiledFileName($tpl_file));
|
||||
|
||||
// make a result, combining Context and compiled_tpl_file
|
||||
$output = $this->_fetch($compiled_tpl_file, $buff, $tpl_path);
|
||||
// compile
|
||||
$buff = $this->_compile($tpl_file, $compiled_tpl_file);
|
||||
|
||||
// make a result, combining Context and compiled_tpl_file
|
||||
$output = $this->_fetch($compiled_tpl_file, $buff, $tpl_path);
|
||||
}
|
||||
|
||||
if(__DEBUG__==3 ) $GLOBALS['__template_elapsed__'] += getMicroTime() - $start;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue