Cache_lite trial. The cache_lite of pear is studied today. Download the latest cache_lite from pear.php.net. Cache_lite is a lightweight cache library class in the pear library class. Indeed light, the code has a total of four files. today we will study the cache_lite of pear.
Download the latest cache_lite from the http://pear.php.net. Cache_lite is a lightweight cache library class in the pear library class. It is really light, and the code has a total of 4 files. Lite. php cache/File. php cache/unction. php cache/output. php. In addition, the scalability is very good. you can add it to your own library class and modify the raiseError function of lite. php.
Add your own library class and start the test. First, the basic cache:
require_once('../libs/cache/Lite.php');
$id='1';
$options = array(
'cacheDir' => '../cache/test/',
'lifeTime' => 60
);
$cache=new Cache_Lite($options);
if($data=$cache->get($id)){
echo $data;
}else{
$data=time();
$cache->save($data);
echo $data;
}
?>
To make the test easier, I set the cache time to 1 minute. After running, you will find a file named Keystore in the ../cache/test/directory, which is the cache file generated by cache_lite. You will find that the data is encrypted. Of course, this is for the sake of security.
When you refresh the page, you will find that the page has not changed. This means that the cache takes effect. it's easy. ^_^. 1 minute later, refresh, haha, changed. In this way, the basic effect of cache is achieved.
Cache_lite can also implement function caching and other functions, I will not introduce the specific, you can access http://www.phpobject.net/blog/books/cache_lite.html
Bytes. Download the latest cache_lite from the http://pear.php.net. Cache_lite is a lightweight cache library class in the pear library class. Indeed light, the code has a total of 4 files...