Under Windows YII2 configuration Memcache

Source: Internet
Author: User
Tags install php yii

Environment:

Operating system: Windows 7;

php:5.6.8

apche:2.4.12

1, first install PHP memcache expansion, installation method is as follows:

1.1 Download memcache Extension DLL:

Http://pecl.php.net/package/memcache/3.0.8/windows

1.2 Copy Php_memcache.dll to Php/ext directory

1.3 Adjust the php.ini, add the configuration at the bottom:

Extension=php_memcache.dll

2. Add YII2 configuration:

Modify in the project config/web.php file

Components>=cache  Configuration  modifications are configured as follows:

The calling method is as follows:

<?PHP/** * Created by Phpstorm. * USER:WANGK * DATE:2015/4/27 * time:10:34*/namespace App\common;  UseYii; classCachemanage {//Cache prefix      Constcache_prefix= ' Myrhythmk_ '; Private Static functionGetKey ($key)     {         returnSelf::cache_prefix.$key; }      Public Static functionGet$key)     {         returnYII::$app->cache->get (Self::getkey ($key)); }      Public  Static  functionSet$key,$value,$duration= 0,$dependency=NULL)     {         returnYII::$app->cache->set (Self::getkey ($key),$value,$duration,$dependency); }      Public  Static  functionDelete$key)     {         returnYII::$app->cache->delete (Self::getkey ($key)); }}

Under Windows YII2 configuration Memcache

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.