Methods for using Memcache in the Zend Framework, zendmemcache_php tutorial

Source: Internet
Author: User
Tags zend framework

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 ...

  • 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.