Zend_cache caching using the ZF Framework (Zend Framework) _php Tutorial

Source: Internet
Author: User
Tags zend zend framework
Zend_cache the basic operation of the file cache, the code has written comments, let's study together
Copy CodeThe code is as follows:
Require_once ("zend/loader.php");
Load Zend Cache Class (Zend_cache)
Zend_loader::loadclass ("Zend_cache");
Front-end Cache settings (life cycle, whether serialization)
$Foptions = Array (' lifetime ', ' automtic_serialization ' = ' = True ');
Back-end cache settings (Cache storage path)
$Boptions = Array (' Cachedir ' = ' cache ');
Turn on cache mode, (core[core],file[file], front-end cache configuration information, backend cache configuration information)
$Cache = zend_cache::factory (' Core ', ' File ', $Foptions, $Boptions);
Determine if the cache exists and load the cache load (' String ' [cache name] if present)
if ($Result = $Cache-Load (' Cache_two '))
{
echo "Cache already exists!
";
Print_r ($Result);
}
Else
{
Reads the file if the cache does not exist and writes the file contents to the lake cache
echo "Cache does not exist!
";
$Filename = ' temp.txt ';
$Fopen = Fopen ($Filename, ' R ');
$Result = Fread ($Fopen, FileSize ($Filename));
Fclose ($Fopen);
Save cache mode Load ($Result [Read Resource], ' cache name ')
$Cache, Save ($Result, ' cache_two ');
Print_r ($Result);
}
?>

http://www.bkjia.com/PHPjc/741850.html www.bkjia.com true http://www.bkjia.com/PHPjc/741850.html techarticle Zend_cache The basic operation of the file cache, the code has written comments, let's learn together. Copy code code as follows: Php require_once ("zend/loader.php");//load Zend Cache class ...

  • 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.