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