Home > Backend Development > PHP Tutorial > How to use zend_cache cache of zf framework (zend framework)_PHP tutorial

How to use zend_cache cache of zf framework (zend framework)_PHP tutorial

WBOY
Release: 2016-07-13 10:35:54
Original
861 people have browsed it

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);
}
?>

www.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...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template