The example in this article describes how to configure and use memcached cache in Yii. Share it with everyone for your reference, the details are as follows:
1. Download the memcached software package, unzip it, and put memcached.exe in any place, such as: d:/memcached/.
2. Start->Run->Enter cmd, open memcached.exe on the command line, in the folder where it is located, enter: memcached.exe -d install Installation
3. Enter memcached. exe -d start Start
4. Add extension=php_memcache.dll.
5. Open the yii configuration file: config/main.php, and add under components:
'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, ), ), ),
6. Use:
Yii::app()->memcache->get(id); Yii::app()->memcache->set(id,value,time);
I hope this article will help everyone based on Yii Frameworks for PHP programming help.
For more articles related to Yii configuration and using memcached cache, please pay attention to the PHP Chinese website!