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