Simple ZendFramework Cache usage example, zendframework_PHP tutorial-php Tutorial

Source: Internet
Author: User
ZendFramework Cache usage is a simple instance, zendframework. A simple example of ZendFramework Cache usage. zendframework this article describes the ZendFramework Cache usage. For your reference, see phprequireZend Cache simple usage example, zendframework

This example describes the Zend Framework Cache usage. We will share this with you for your reference. The details are 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 '); define ('cache _ dir', FDROOT. '/'. 'tmp/');/* config. ini: [cache] cache. needcache = 1cache. frontend. name = Corecache. frontend. lifetime = 7200cache. frontend. automatic_serialization = 1cache. backend. name = File * // * option reference Manual * // * create a cache object */$ frontendOptions = $ config-> cache-> frontend-> toArray (); $ backendOptions = $ config-> 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 ($ fro NtendName, $ backendName, $ frontendOptions, $ backendOptions); Zend_Registry: set ('cache', $ _ cache ); /* use cache */$ viewRenderer =$ _ cache-> load ('viewrenderer'); // try to load the variable if (! $ ViewRenderer instanceof Something) // loading failed {$ viewRenderer = new Something ();/* some other work */$ _ cache-> save ($ viewRenderer, 'viewrenerer'); // Save the variable to the memory change}/* This is only an application that can easily cache the entire page or store the cache in the database or memory. */?>

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.