Re-study the next cache_lite_php tutorial

Source: Internet
Author: User
The evening detailed look at the next cache_lite, the function than I imagined more powerful. Of course I have not yet found out whether it supports the ability to directly save PHP code to cache, but I think it is possible to extend the implementation.

Here are a few examples:

require_once ('.. /libs/cache/lite.php ');

$options= Array (
' Cachedir '='.. /cache/test/',
' filelocking '=true,
' Writecontrol '=true,
' Readcontrol '=false,
' Filenameprotection '=false,//Close file name Safe mode. The cache ID and group name are applied directly to the file name of the cache file, so use special characters with caution.
' Automaticserialization '=false,//Turn off automatic sequences
' Hasheddirectorylevel '=2,//Set level two 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;
}
?>


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=newCache_lite_output($options);

if (! ($cache -Start(' Id_of_the_page '))) {
//No cache found!
Echo' Test time: '. Time().'
Test
';
$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= newcache_lite_function($options);

$cache -Pager(' Function_to_bench ', A, $);

functionFunction_to_bench($arg 1, $arg 2)
{
Echo"This is the output of the function Function_to_bench ($arg 1, $arg 2)!
";
Return"This is the result of the function function_to_bench ($arg 1, $arg 2)!
";
}
?>

http://www.bkjia.com/PHPjc/317938.html www.bkjia.com true http://www.bkjia.com/PHPjc/317938.html techarticle The evening detailed look at the next cache_lite, the function than I imagined more powerful. Of course I haven't found out yet whether it supports the ability to save PHP code to cache directly, but I think it should be ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.