Installing the Php_memcache.dll Extension
1. First put the Php_memcache.dll file in the E:\server\php\ext directory
(php_memcache.dll:http://windows.php.net/downloads/pecl/releases/memcache/3.0.8/)
Be sure to download the appropriate php_memcache.dll,thread based on your PHP version and Thread safety safety
Phpinfo () view, enabled for TS version, or NTS version
2. Modify the php.ini file
First determine if the Extension_dir is consistent with the directory where the extension file is placed (that is, the Php_memcache.dll location), and then
Add Extension=php_memcache.dll, and finally restart Apache, you can see Memcache in Phpinfo.
3. CMD Open command
Enter as Administrator (can enter as Administrator in C:\Windows\System32\cmd.exe),
Put the memcached.exe in the root of your code and run it in a small black window:
D://Enter your Memcached.exe disk
Memcached.exe-d Install//Perform installation memcached
memcached.exe-d Start//Start command
Netstat-an//View open item
4. Place the following code in the YII framework common/main.php
' Components ' = [
' Cache ' = [
' Class ' = ' Yii\caching\memcache ',
' Servers ' = [
[
' Host ' = ' server1 ',
' Port ' = 11211,
' Weight ' = 100,
],
[
' Host ' = ' Server2 ',
' Port ' = 11211,
' Weight ' = 50,
],
],
],
],
5. Create the file in your project root directory, enter the following code
This is the controller inside to load
Use Yii\caching\memcache;
Public Function Actionindex ()
{
Echo Phpinfo ();
Instantiate the Memcache class
$memcache = new Memcache;
$memcache->set (' 123 ', ' 234 ');
echo $memcache->get (' 123 ');
}
If the output is as follows
234
Is installed correctly
Installation of memcache and configuration and testing in YII framework