Home> php教程> PHP开发> body text

How to configure and use memcached cache in Yii

高洛峰
Release: 2016-12-30 16:38:44
Original
1382 people have browsed it

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, ), ), ),
Copy after login

6. Use:

Yii::app()->memcache->get(id); Yii::app()->memcache->set(id,value,time);
Copy after login

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!

Related labels:
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
    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!