The examples in this article describe the cache usage of Zend Framework caches. Share to everyone for your reference, as follows:
<?phprequire ' 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 ');d efine (' CACHE_DIR ') , Fdroot. ' /'.' tmp/');/* configuration file Config.ini:[cache]cache.needcache=1cache.frontend.name=corecache.frontend.lifetime= 7200cache.frontend.automatic_serialization=1cache.backend.name=file*//* option Reference manual *//* creating the 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 '); Attempting to load variable i from cacheF (! $viewRenderer instanceof Something)//load unsuccessful {$viewRenderer = new Something ();/*some other work*/$_cache->save ($vi Ewrenderer, ' viewrenderer ');//save variables to swap}/* This is an app, it's easy to cache entire pages, or you can store the cache in a database or memory. */?>
More interested in Zend related content readers can view the topic: "Zend framework of the introductory tutorial", "PHP Excellent Development Framework Summary", "Yii framework Introduction and common skills Summary", "thinkphp Introductory Tutorial", "PHP object-oriented Programming introduction tutorial "," Introduction to Php+mysql Database Operation "and" PHP common database Operation Skills Summary "
It is hoped that this article will help you to design PHP based on the Zend Framework framework.