This article mainly introduces the ZendFramework Cache Usage, analyzes the specific steps for ZendFramework to use the Cache in the form of a simple example, and describes the specific usage techniques of the configuration file and Cache, for more information about Zend Framework Cache Usage, see the examples in this article. 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. */?>