在用建立一个站点(只用引擎也一样)时,开启缓存之后cache和templates_c这两个目录用不了多长时间就充满了上千个文件乃至几十万个文件,操作一个包含数量巨大的文件的目录本来就很慢,这样会导致这两个目录的文件读取、删除、更新都很慢,本打算写一个cache handler来解决这个问题,在跟踪代码的时候发现已经解决了这个问题,那就是use_sub_dirs属性,将该属性设置为true即可。示例代码

[coolcode lang=""]<?
 
require ‘../libs/.class.’;
 
$ = new ;
 
$->use_sub_dirs = true;
 
$->compile_check = true;
$->debugging = true;
$->caching = true;
$->cache_lifetime = 60;
$->assign(“Name”,”Fred Irving Johnathan Bradley Peppergill”);
$->assign(“FirstName”,array(“John”,”Mary”,”James”,”Henry”));
$->assign(“LastName”,array(“Doe”,”Smith”,”Johnson”,”Case”));
$->assign(“Class”,array(array(“A”,”B”,”C”,”D”), array(“E”, “F”, “G”, “H”),
      array(“I”, “J”, “K”, “L”), array(“M”, “N”, “O”, “P”)));
 
$->assign(“contacts”, array(array(“phone” => “1″, “fax” => “2″, “cell” => “3″),
      array(“phone” => “555-4444″, “fax” => “555-3333″, “cell” => “760-1234″)));
 
$->assign(“option_values”, array(“NY”,”NE”,”KS”,”IA”,”OK”,”TX”));
$->assign(“option_output”, array(“New York”,”Nebraska”,”Kansas”,”Iowa”,”Oklahoma”,”Texas”));
$->assign(“option_selected”, “NE”);
 
$->display(‘index.tpl’);
 
?>
[/coolcode]

对应中编辑Class\template.文件第58行附近更改var $use_sub_dirs = false;var $use_sub_dirs = true;即可。