Today I will study pear's cache_lite.
fromThe latest cache_lite was downloaded on. cache_lite is a light cache library class in the pear library class. It's indeed lightweight, with a total of 4 files. cache/ cache/ cache/ cache/. Moreover, it has very good scalability. Add it to your own library class and mainly modify the raiseError function.
After adding your own library class, start testing. First, basic cache:
In order to test the effect to be easier to discover, I set the cache time to 1 minute. After running, you go to the ../cache/test/ directory and find a file cache_c21f969b5f03d33d43e04f8f136e7682_c4ca4238a0b923820dcc509a6f75849b, which is the cache file generated by cache_lite. After opening it, you will find that the data is encrypted. Of course, this is for safety reasons.
When refreshing the page, you will find that the page has not changed much. This is the cache that works, it’s very simple. ^_^. After 1 minute, refreshed, haha, it changed. This achieves the basic effect of caching.
cache_lite can also implement function cache and other functions. I won't introduce the details, you can visit it./blog/books/cache_lite.html
fromThe latest cache_lite was downloaded on. cache_lite is a light cache library class in the pear library class. It's indeed lightweight, with a total of 4 files. cache/ cache/ cache/ cache/. Moreover, it has very good scalability. Add it to your own library class and mainly modify the raiseError function.
After adding your own library class, start testing. First, basic cache:
<?
require_once('../libs/cache/');
$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;
}
?>
In order to test the effect to be easier to discover, I set the cache time to 1 minute. After running, you go to the ../cache/test/ directory and find a file cache_c21f969b5f03d33d43e04f8f136e7682_c4ca4238a0b923820dcc509a6f75849b, which is the cache file generated by cache_lite. After opening it, you will find that the data is encrypted. Of course, this is for safety reasons.
When refreshing the page, you will find that the page has not changed much. This is the cache that works, it’s very simple. ^_^. After 1 minute, refreshed, haha, it changed. This achieves the basic effect of caching.
cache_lite can also implement function cache and other functions. I won't introduce the details, you can visit it./blog/books/cache_lite.html