Extended memcache module in PHP

Source: Internet
Author: User
When I studied the components supported by yii in the memcache extension module under PHP, I found that my PHP does not support the memcache module, so I tried to extend it.


Local environment: win8.1


Development Environment: php 5.5


  • Step 1: First download all the required file packages. I have already packed them. you can download them here.

  • There are two main files in the package: php_memcache.dll and Memcached-win64 ps: memcached installation package is 64-bit


  • Step 2: install the memcached installation package

  • Unzip the installation package to a disk:

    E: \ wamp \ bin \ memcached \ memcached.exe


    Then enter the following command on the terminal (that is, the cmd command interface) to install the windows service:

    Note: this must be the administrator privilege. Otherwise, the installation will fail.

    E: \ wamp \ bin \ memcached> memcached.exe-d install

    Run the following command to start the instance:

    E: \ wamp \ bin \ memcached> memcached.exe-d start


    In this way, memcache is installed.


  • Step 3: install php extension memcache

  • First, put the downloaded php_memcache.dll to the ext directory of php:

    Example: E: \ Wamp \ bin \ php \ php5.3.11 \ ext \ php_memcache.dll

    Open the php. ini file:

    My php. ini location: E: \ Wamp \ bin \ php \ php5.3.11 \ php. ini

    Add a line on php. ini:

    Extension = php_memcache.dll

    Restart the apache service of Wampserver


  • Step 4: View phpinfo ();
  • Step 5: test memcache
  • Test code:

     Connect ('2017. 0.0.1 ', 11211) or die ("cocould not connect"); // connect to the Memcached server $ memcache-> set ('key', 'This is a memcache test! ', MEMCACHE_COMPRESSED, 50); // set a variable to the memory. The name is key and the value is test $ get_value = $ memcache-> get ('key '); // retrieve the key value from memory echo $ get_value; echo'
    Server version: '. $ memcache-> getVersion ();?>

    Test results:

    This is a memcache test!Server version:1.4.4-14-g9c660c0
    So far, the PHP memcache extension has been successfully completed.

    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.