Evening in detail looked at the next cache_lite, the function is more powerful than I imagined. Of course I haven't found out yet whether it supports the ability to save PHP code directly to cache, but I think it should be extensible.
Here are a few examples:
?
Require_once ('.. /libs/cache/lite.php ');
$options= Array (
' Cachedir '=>'.. /cache/test/',
' Filelocking '=>True,
' Writecontrol '=>True,
' Readcontrol '=>False,
' Filenameprotection '=>False,Turn off file name Safe mode. Cache IDs and group names are applied directly to the file name of the cache file, so be careful with special characters.
' Automaticserialization '=>False,Turn off automatic sequence
' Hasheddirectorylevel '=>2,//Set level two cache path
' lifeTime ' => 60
);
$Cache = new cache_lite($options);
$id=' Test ';
if ($data=$Cache->get($id,' Test ')) {
echo $data;
}else{
$data=time();
$Cache->save($data);
echo $data;
}
?>
Caching the output
?
Require_once ('.. /libs/cache/lite.php ');
Require_once ('.. /libs/cache/lite/output.php ');
$options= Array (
' Cachedir '=>'.. /cache/test/',
' lifeTime ' => ,
' Pearerrormode ' => cache_lite_error_die
);
$cache =new cache_lite_output ( $options );
if (!) ( $cache start ( ' id_of_the_page ' )) {
&NBSP // not found cache !
echo ' test time: ' . Time (). ' <br>test<br> ' ;
$cache end (); // buffered output is now stored in a cache file
}
?>
To cache a function
?
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 ' , , );
function function_to_bench ( $arg 1 , $arg 2 )
{
&NBSP;&NBSP;&NBSP;&NBSP;ECHO&NBSP this is the output of the function function_to_bench ($arg 1, $arg 2) !<br> ";
return this is the result of the Function function_to_bench ($arg 1, $arg 2) !<br> ";
}
?>