Study cache_lite again. At night, I took a detailed look at cache_lite, which is more powerful than I thought. Of course, I haven't found out whether it supports directly saving PHP code for caching, but I think it should be detailed at night to see cache_lite, which is much more powerful than I think. Of course, I have not found whether it supports directly saving PHP code for caching, but I think it can be extended.
Here are several examples:
Require_once ('../Libs/cache/Lite. php');
$ Options= Array (
'Cachedir'=>'../Cache/test /',
'Filelocking'=>True,
'Writecontrol'=>True,
'Readcontrol'=>False,
'Filenameprotection'=>False,// Disable the file name security mode. The cache id and group name are directly applied to the name of the cache file, so be careful when using special characters.
'Icicserialization'=>False,// Disable automatic sequence
'Hasheddirectorylevel'=>2,// Set the two-level cache path
'Lifetime'=>60
);
$ Cache= NewCache_Lite($ Options);
$ Id='Test';
If ($ Data=$ Cache->Get($ Id,'Test')){
Echo$ Data;
} Else {
$ Data=Time();
$ Cache->Save($ Data);
Echo$ Data;
}
?>
Cache output
Require_once ('../Libs/cache/Lite. php');
Require_once ('../Libs/cache/Lite/output. php');
$ Options= Array (
'Cachedir'=>'../Cache/test /',
'Lifetime'=>60,
'Pearerrormode'=>CACHE_LITE_ERROR_DIE
);
$ Cache= NewCache_Lite_Output($ Options);
If (! ($ Cache->Start('Id _ of_the_page'))){
// No Cache found!
Echo'Test time :'.Time().'
Test
';
$ Cache->End();// The buffered output is now stored in a cache file.
}
?>
Cache functions
require_once('../libs/cache/Lite.php');
require_once('../libs/cache/Lite/Function.php');
$options = array(
'cacheDir' => '../cache/test/',
'lifeTime' => 3600,
'pearErrorMode' => CACHE_LITE_ERROR_DIE
);
$cache = new Cache_Lite_Function($options);
$cache->call('function_to_bench', 12, 45);
function function_to_bench($arg1, $arg2)
{
echo "This is the output of the function function_to_bench($arg1, $arg2) !
";
return "This is the result of the function function_to_bench($arg1, $arg2) !
";
}
?>
Bytes. Of course, I have not found whether it supports directly saving PHP code for caching, but I think it should be...