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