晚上详细的看了下cache_lite,功能比我想象中的强大的多。当然目前我还没有发现它是否支持直接保存PHP代码来缓存的功能,不过我想应该是可以扩展实现的。
这里有几个例子:
天龙企业网站管理系统,基于.net2.0+access开发,系统架构采用MVC设计模式,是一个十分优秀的.net企业管理系统。其中包括产品发布,新闻发布,企业简价,企业文化,下载中心,客户留言等功能。在V2.0 sp2 基础上再次升级: 1、修正了前台的投票调查功能。 2、增强系统安全性,增加了防SQL注入功能 3、修补了后台漏洞 4、增加了前台游客留言的字符过滤,自动过滤html格式以增强系统安
require_once('../libs/cache/Lite.php');
$options = array(
'cacheDir' => '../cache/test/',
'fileLocking' =>true,
'writeControl'=>true,
'readControl'=>false,
'fileNameProtection'=>false,//关闭文件名安全模式。cache id和组名将直接应用到 cache文件的文件名,所以要小心使用特殊字符.
'automaticSerialization'=>false,//关闭自动序列
'hashedDirectoryLevel'=>2,//设置两级缓存路径
'lifeTime' => 60
);
$Cache = new Cache_Lite($options);
$id='test';
if($data=$Cache->get($id,'test')){
echo $data;
}else{
$data=time();
$Cache->save($data);
echo $data;
}
?>
对输出进行缓存
require_once('../libs/cache/Lite.php');
require_once('../libs/cache/Lite/output.php');
$options = array(
'cacheDir' => '../cache/test/',
'lifeTime' => 60,
'pearErrorMode' => CACHE_LITE_ERROR_DIE
);
$cache =new Cache_Lite_Output($options);
if (!($cache->start('id_of_the_page'))) {
// 没有发现Cache !
echo 'test time:'.time().'
test
';
$cache->end(); // 缓冲的输出现在被存储到一个cache文件中
}
?>
对函数进行缓存
require_once('../libs/cache/Lite.php');
require_once('../libs/cache/Lite/Function.php');
$options = array(
'cacheDir' => '../cache/test/',
'lifeTime' => 3600,
'pearErrorMode' => CACHE_LITE_ERROR_DIE
);
$cache = new Cache_Lite_Function($options);
$cache->call('function_to_bench', 12, 45);
function function_to_bench($arg1, $arg2)
{
echo "This is the output of the function function_to_bench($arg1, $arg2) !
";
return "This is the result of the function function_to_bench($arg1, $arg2) !
";
}
?>










