Zendmemcache is used in zend framework.

Source: Internet
Author: User
Tags zend framework

Zendmemcache is used in zend framework.

This example describes how to use memcache in zend framework. We will share this with you for your reference. The details are as follows:

In the zend framework project, the following are the specific methods:

1. Find Bootstrap. php and add the following initialization method (Note: Bootstrap. php is used to initialize and load all operations ):

Protected function _ initMemcache () {$ frontendOpts = array ('caching' => true, 'lifetime' => 1800, // cache life cycle of 3 minutes, set 'ic IC _ serialization' => true) according to your project requirements; $ backendOpts = array ('servers' => array ('host' => '100. 0.0.1 ', 'Port' => 11211), 'compression' => false); $ memcache = Zend_Cache: factory ('core', 'memcached', $ frontendOpts, $ backendOpts); Zend_Registry: set ('memcache', $ memcache );}

2. Call at the desired location:

For example, call the link in your IndexController

Public function indexAction () {$ memcache = Zend_Registry: get ('memcache'); // if (! $ Datalink = $ memcache-> load ('datalink ') {$ link = new Blog_Model_Friendlink (); $ datalink = $ link-> listshi (); // print_r ($ datalink); die; $ memcache-> save ($ datalink, 'datalink ');} $ this-> view-> datalink = $ datalink ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.