Home >Backend Development >PHP Tutorial >yii --memcached cache configuration_PHP tutorial
Start->Run->Enter cmd, open memcached.exe on the command line, and enter the folder where it is located. Enter: memcached.exe -d install to install
Enter memcached.exe -d start to start
Open the yii configuration file: config/main.php and add under components:
[html]
'memcache'=>array(
'class'=>'CMemCache',
'servers'=>array(
array(
'host'=>'127.0.0.1',
'port'=>11211,
'weight'=>60,
),
array(
'host'=>'127.0.0.1',
'port'=>11211,
'weight'=>40,
),
),
),
'memcache'=>array(
'class'=>'CMemCache',
‘servers’=>array(
array(
'host'=>'127.0.0.1',
'port'=>11211,
'weight'=>60,
array(
'host'=>'127.0.0.1',
'port'=>11211,
'weight'=>40,
),
),
),
Use:
[html]
Yii::app()->memcache->get(id);
Yii::app()->memcache->set(id,value,time);
Yii::app()->memcache->get(id);
Yii::app()->memcache->set(id,value,time);
http://www.bkjia.com/PHPjc/477582.html
http: //www.bkjia.com/PHPjc/477582.html