Methods for using Memcache in the Zend Framework, Zendmemcache
The example in this article describes the method of using Memcache in the Zend Framework. Share to everyone for your reference, as follows:
In the Zend Framework project, the following are the specific methods:
1. Locate bootstrap.php Add the following initialization method ( Note: bootstrap.php is the initialization load all operations ):
protected function _initmemcache () {$frontendOpts = array (' caching ' + = True, ' lifetime ' = + 1800,//Cache life cycle 3 minutes, Set ' Automatic_serialization ' to true for your project needs); $backendOpts = Array (' Servers ' =>array (' host ' = = ') 127.0.0.1 ', ' port ' = 11211), ' compression ' = false); $memcache = Zend_cache::factory (' Core ', ' Memcached ', $ Frontendopts, $backendOpts); Zend_registry::set (' Memcache ', $memcache);}
2. Call in the location you want:
For example, call links in your Indexcontroller
Public Function indexaction () {$memcache =zend_registry::get (' memcache ');//Links if (! $datalink = $memcache->load (' Datalink ') {$link =new blog_model_friendlink (); $datalink = $link->listshi ();//print_r ($datalink);d ie; $memcache- >save ($datalink, ' datalink '); } $this->view->datalink= $datalink;}
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 "
I hope this article is helpful to you in PHP programming.
Articles you may be interested in:
- Zend Framework Tutorial Model basic rules and how to use them
- Zend Framework Tutorial Zend_layout Layout Assistant Detailed
- Resolution of URL case problem in Zend Framework frame
- Zend Framework 2.0 Event Manager (the EventManager) Getting Started tutorial
- Zend Framework Page Cache instance
- Very useful Zend Framework paging class
- Layout in the Zend Framework (modular layout) detailed
- Zend Framework Configuration Operations Database instance analysis
- Windows Zendframework Project Environment Setup (via command line configuration)
- Zend Framework Tutorial Model Usage Simple Example
http://www.bkjia.com/PHPjc/1106120.html www.bkjia.com true http://www.bkjia.com/PHPjc/1106120.html techarticle using Memcache in the Zend Framework, Zendmemcache This example describes how memcache is used in the Zend Framework. Share to everyone for your reference, specifically as follows: Zend Framew ...