The example in this article describes the cache usage for Zend Framework caching. Share to everyone for your reference, specific as follows:
<?php require ' zend/loader.php ';
Zend_loader::loadclass (' Zend_cache ');
Zend_loader::loadclass (' Zend_config ');
Zend_loader::loadclass (' zend_registry ');
$config = new Zend_config_ini (' Configsecr/config.ini '); Define (' Cache_dir ', fdroot. /'.'
tmp/');
/* Configuration file Config.ini: [Cache] cache.needcache=1 Cache.frontend.name=core cache.frontend.lifetime=7200 Cache.frontend.automatic_serialization=1 cache.backend.name=file///////////////* Set Cache object/* $frontendOptions = $
Config->cache->cache->frontend->toarray ();
$backendOptions = $config->cache->cache->backend->toarray ();
$frontendName = $frontendOptions [' name '];
unset ($frontendOptions [' name ']);
$backendName = $backendOptions [' name '];
unset ($backendOptions [' name ']); if (Empty ($backendOptions [' Cache_dir ']) {$backendOptions [' cache_dir '] = cache_dir;} $_cache = Zend_cache::factory ($
Frontendname, $backendName, $frontendOptions, $backendOptions);
Zend_registry::set (' cache ', $_cache); /* Use cache*/$viewRenderer = $_cache->loAD (' Viewrenderer ');
An attempt was made to load a variable from the cache if (! $viewRenderer instanceof Something)//failed to load {$viewRenderer = new something (); /*some other work*/$_cache->save ($viewRenderer, ' viewrenderer ');/save variable to save}/* This is just an application, you can easily cache an entire page, or you can save the cache to a database or memory.
* *?>
More interested in Zend related content readers can view the site topics: "The introduction of the Zend Framework frame", "PHP Excellent Development Framework Summary", "Yii framework Introduction and common skills Summary", "thinkphp Introductory Course", "PHP object-oriented Programming Program , "Php+mysql Database operation Introduction Tutorial" and "PHP common database Operation Skills Summary"
I hope this article will help you with the PHP program design based on the Zend Framework.