Home  >  Article  >  Backend Development  >  yii --memcached cache configuration_PHP tutorial

yii --memcached cache configuration_PHP tutorial

WBOY
WBOYOriginal
2016-07-14 10:09:58849browse

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

www.bkjia.com

true

http: //www.bkjia.com/PHPjc/477582.html

Start-Run-enter cmd, open memcached.exe on the command line, in the folder where it is located, enter: memcached.exe - d install Install and enter memcached.exe -d start to start and open the yii configuration file: conf...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn