Zend_cache usage of zf framework (zend Framework) _ PHP Tutorial

Source: Internet
Author: User
Zend_cache usage of the zf framework (zend Framework ). The basic operations of Zend_Cache file cache are as follows :? Phprequire_once (ZendLoader. php); basic operations for loading Zend cache class Zend_Cache file cache. comments have been written in the code. let's take a look.

The code is as follows:


Require_once ("Zend/Loader. php ");
// Load Zend cache class (Zend_Cache)
Zend_Loader: loadClass ("Zend_Cache ");
// Frontend cache settings (lifecycle, serialization or not)
$ Foptions = array ('lifetime' => 60, 'automtic _ serialization' => true );
// Backend cache settings (cache storage path)
$ Boptions = array ('cachedir' => 'cache ');
// Enable the cache mode (Core [Core], File [File], front-end cache configuration information, and backend cache configuration information)
$ Cache = Zend_Cache: factory ('core', 'file', $ Foptions, $ Boptions );
// Determine whether the cache exists. If yes, load the cache ('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 );
// Load ($ Result [read resource], 'cache name ')
$ Cache-> save ($ Result, 'cache _ two ');
Print_r ($ Result );
}
?>

The pipeline code is as follows :? Php require_once ("Zend/Loader. php"); // load the 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.