Heim > Artikel > Backend-Entwicklung > cached failure cache_lite试用
今天研究下pear的cache_lite。
从http://pear.php.net上下载了最新的cache_lite。cache_lite是pear库类中一个轻型的cache库类。的确轻型,代码总计4个文件。lite.php cache/File.php cache/unction.php cache/output.php。而且扩展性特别好,加入到自己的库类,主要修改下lite.php的raiseError函数。
加入自己的库类后,开始测试。首先基本的缓存:
<span><br><span> <br></span><span>require_once(</span><span>'../libs/cache/Lite.php'</span><span>); <br></span><span>$id</span><span>=</span><span>'1'</span><span>; <br></span><span>$options </span><span>= array( <br> </span><span>'cacheDir' </span><span>=> </span><span>'../cache/test/'</span><span>, <br> </span><span>'lifeTime' </span><span>=> </span><span>60 <br></span><span>); <br></span><span>$cache</span><span>=new </span><span>Cache_Lite</span><span>(</span><span>$options</span><span>); <br>if(</span><span>$data</span><span>=</span><span>$cache</span><span>-></span><span>get</span><span>(</span><span>$id</span><span>)){ <br> echo </span><span>$data</span><span>; <br>}else{ <br> </span><span>$data</span><span>=</span><span>time</span><span>(); <br> </span><span>$cache</span><span>-></span><span>save</span><span>(</span><span>$data</span><span>); <br> echo </span><span>$data</span><span>; <br>} <br></span><span>?> <br></span></span>
以上就介绍了cached failure cache_lite试用,包括了cached failure方面的内容,希望对PHP教程有兴趣的朋友有所帮助。