Zend Framework Cache usage Simple instance, zendframework
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.
Articles you may be interested in:
- Zend Framework framework of the zend_mail implementation of the email message verification function and solve the title garbled method
- Zend Framework Tutorial Zend_form component implement form submission and display Error prompt method
- Zend Framework implements multi-file upload function instances
- Zend Framework Introduction Environment configuration and the first Hello World example (with demo source download)
- Zend Framework Tutorial to connect the database and perform additions and deletions of the method (attached to the demo source download)
- Zend Framework Framework Tutorial Zend_db_table_rowset Usage Example Analysis
- Zend Framework Tutorial Zend_db_table_row Usage Example Analysis
- Zend Framework Tutorial Zend_db_table Usage
- Zend Framework Introductory Knowledge Point Summary
- Zend Framework basic Page Layout analysis
- Zend framework generate verification code and implement Verification Code verification function (with demo source download)
http://www.bkjia.com/PHPjc/1111887.html www.bkjia.com true http://www.bkjia.com/PHPjc/1111887.html techarticle The Zend Framework caches a simple instance of cache usage, Zendframework This example describes the Zend framework cache usage. Share to everyone for your reference, specifically as follows: Phprequire ' Zend ...