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.