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. */?>