Zend_Cache文件缓存的基本操作,代码中有已写注释,大家共同学习一下吧
<?php<BR>require_once("Zend/Loader.php");<BR>//载入Zend缓存类(Zend_Cache)<BR>Zend_Loader::loadClass("Zend_Cache");<BR>//前端缓存设置(生命周期、是否序列化)<BR>$Foptions = array('lifetime' => 60 , 'automtic_Serialization' => true);<BR>//后端缓存设置(缓存存放路径)<BR>$Boptions = array('cacheDir' => 'cache');<BR>//开启缓存模式,(Core[核心],File[文件],前端缓存配置信息,后端缓存配置信息)<BR>$Cache = Zend_Cache::factory('Core','File',$Foptions,$Boptions);<BR>//判断缓存是否存在,如果存在则载入缓存load('String'[缓存名称])<BR>if ($Resu<i style="color:transparent">本文来源gaodai$ma#com搞$$代**码)网8</i><strong>搞代gaodaima码</strong>lt = $Cache -> load('cache_two')) <BR>{<BR> echo "缓存已经存在!<br>";<BR> print_r($Result);<BR>}<BR>else<BR>{<BR> //如果缓存不存在则读取文件,并将文件内容写入湖缓存<BR> echo "缓存不存在!<br>";<BR> $Filename = 'temp.txt';<BR> $Fopen = fopen($Filename,'r');<BR> $Result = fread($Fopen, filesize($Filename));<BR> fclose($Fopen);<BR> //保存缓存方式load($Result[读取资源],'缓存名称')<BR> $Cache -> save($Result,'cache_two');<BR> print_r($Result);<BR>}<BR>?><BR>