帝国cms 生成缓存文件函数,对于经常读取且需要大量读取的文件进行缓存是非常有必要的,值得借鉴学习。参考代码如下:
//会员组缓存 function GetMemberLevel(){ global $empire,$dbtbpre; $file=eReturnTrueEcmsPath()."e/data/dbcache/MemberLevel.php"; $sql=$empire->query("select * from {$dbtbpre}enewsmembergroup order by groupid"); while($r=$empire->fetch($sql)) { $levels.="\$level_r[".$r[groupid]."]=Array('groupid'=>".$r[groupid].", 'groupname'=>'".addslashes($r[groupname])."', 'type'=>".$r['type'].", 'level'=>".$r[level].", 'checked'=>".$r[checked].", 'favanum'=>".$r[favanum].", 'daydown'=>".$r[daydown].", 'msglen'=>".$r[msglen].", 'regchecked'=>".$r[regchecked].", 'spacestyleid'=>".$r[spacestyleid].", 'dayaddinfo'=>".$r[dayaddinfo].", 'infochecked'=>".$r[infochecked].", 'plchecked'=>".$r[plchecked].", 'msgnum'=>".$r[msgnum]."); "; } //管理组 $agcacher=eGetCacheMAdmin(); //内部组 $igcache=eGetCacheMInGroup(); $levels="<?php //level \$level_r=array(); ".$levels.$agcacher['agcache'].$igcache." //level ?>"; $fp=@fopen($filepath,"w"); @fputs($fp,$levels); @fclose($fp); }
如果本文对你有帮助,欢迎打赏本站