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.