The basic operations of Zend_Cache file caching, there are comments written in the code, let’s learn together
Copy the code The code is as follows:
require_once("Zend/Loader.php");
//Load Zend cache class (Zend_Cache)
Zend_Loader::loadClass("Zend_Cache");
//Front-end cache settings (lifecycle, serialization or not)
$Foptions = array('lifetime' => 60 , 'automtic_Serialization' => true);
//Back-end cache settings (cache Storage path)
$Boptions = array('cacheDir' => 'cache');
//Enable cache mode, (Core[core], File[file], front-end cache configuration information, back-end cache Configuration information)
$Cache = Zend_Cache::factory('Core','File',$Foptions,$Boptions);
//Determine whether the cache exists, and if it exists, load the cache load('String' [cache name])
if ($Result = $Cache -> load('cache_two'))
{
echo "The cache already exists!
";
print_r($ Result);
}
else
{
//If the cache does not exist, read the file and write the file content to the lake cache
echo "The cache does not exist!
";
$Filename = 'temp.txt';
$Fopen = fopen($Filename,'r');
$Result = fread($Fopen, filesize($Filename));
fclose($Fopen);
//Save cache method load($Result[read resource],'cache name')
$Cache -> save($Result,'cache_two');
print_r($Result);
}
?>
http://www.bkjia.com/PHPjc/741850.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/741850.htmlTechArticleThe basic operation of Zend_Cache file caching. There are comments written in the code. Let’s study together. Copy the code as follows: ?php require_once("Zend/Loader.php"); //Load Zend cache class...