PHP Extended memcache Module

Source: Internet
Author: User

When studying the components that Yii supports, I find that PHP does not support the Memcache module, so I try to expand it.


Native Environment: win8.1


Development environment: PHP 5.5


    • The first step: first to download the required file package completely, I have packaged it, here can download.


There are two main files in the package:Php_memcache.dll and Memcached-win64 ps:memcached are 64-bit installed

    • Step Two: Install memcached      


1. Unzip the installation package to a specific disk:

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


2. Under terminal (also known as cmd Command Interface), enter the following command to install the Windows service:

Note: This must be Administrator privileges Oh, otherwise there is no way to install E:\WAMP\BIN\MEMCAChed>memcached.exe-d Install 3. Enter the following command to start: E:\WAMP\BIN\MEMCAChed>memcached.exe-d start
This completes the installation memcache.
    • Step three: Install the PHP extension memcache

1. Place the downloaded Php_memcache.dll in the PHP ext directory:Example: E:\Wamp\bin\php\php5.3.11\ext\php_memcache.dll
2. Open the php.ini file:my php.ini is here: E:\Wamp\bin\php\php5.3.11\php.ini
3. Add a line on the php.ini:Extension=php_memcache.dll 4. Restart Wampserver's Apache service
    • Fourth step: View Phpinfo ();
    • Fifth Step: Test memcache
Test Code:
<span style= "FONT-SIZE:18PX;" ><?php$memcache = new Memcache (); Create a Memcache object $memcache->connect (' 127.0.0.1 ', 11211) or Die ("Could not Connect"); Connect memcached server $memcache->set (' key ', ' This is a memcache test! ', memcache_compressed, 50); Set a variable into memory, the name is the key value is Test$get_value = $memcache->get (' key '); Remove the value of key from memory echo $get _value;echo ' <br>server version: '. $memcache->getversion ();? ></span>

Test Results:
<span style= "FONT-SIZE:18PX;" >this is a memcache test! Server version:1.4.4-14-g9c660c0</span>

the PHP memcache extension has been successfully completed.

Extending the Memcache module under PHP

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.