Home  >  Article  >  php教程  >  yii --memcached缓存的配置

yii --memcached缓存的配置

WBOY
WBOYOriginal
2016-06-13 10:56:001279browse

开始->运行->输入cmd,命令行打开memcached.exe,所在文件夹,输入:memcached.exe -d install  安装
 输入memcached.exe -d start 启动

 打开yii配置文件:config/main.php , 在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, 
            ), 
        ), 
 ),

 使用:
[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);

 

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
Previous article:php比较运算符的bugNext article:php mongodb 注入