Home > php教程 > php手册 > body text

yii --memcached缓存的配置

WBOY
Release: 2016-06-13 10:56:00
Original
1286 people have browsed it

开始->运行->输入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);

 

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!