<?php $cachFile = './index.php'; //缓存文件存在且时间不超过一小时,则直接使用缓存的结果集,不在进行任何的MySQL查询了 if(file_exists($cacheFile) && time()-filemtime($cachFile) < 3600) { //使用缓存中的结果 $arrResult = include($cachFile); } else { $objPage = new Page_IndexModel($arrParams); $arrResult = $objPage->process(); $strContent = "<?php \n return ".var_export($arrResult, true)."\n;"; //将结果集缓存 file_put_contents($cachFile, $strContent); } //获得结果后smarty赋值 $smarty->assign($arrResult); //输出模板 $smarty->display();
PHP文件file缓存实现方式
猜你喜欢
转载自hnlixf.iteye.com/blog/2298509
今日推荐
周排行