Using Redis extensions in YII2

Source: Internet
Author: User
Redis is a very good NoSQL database, and the benefit of memcached is that it can persist data. To use Redis in Yii2, first expand Redis. Redis can be added to the Composer.json.

"Require": {        "php": ">=5.4.0",        "Yiisoft/yii2": ">=2.0.5",        "Yiisoft/yii2-bootstrap": "*",        " Yiisoft/yii2-swiftmailer ":" * ",        " Yiisoft/yii2-smarty ":" * ",        " Yiisoft/yii2-redis ":" * "    },

Then use the command composer update, or use the command composer update--prefer-dist Yii-soft/yii2-redis directly.

The next step is to configure the components.

Redis ' Redis ' = [    ' class ' = ' yii\redis\connection ',    ' hostname ' = ' 127.0.0.1 ',    ' port ' = 6379,    ' database ' = 0,//has 16 library 0-15 default, if it is a cluster, there is only one 0. ],

Finally, it can be used.

$redis = Yii:: $app->redis; $redis->set (' City ', ' Beijing '); $value = $redis->get ("City"); Echo ' The value of city In Redis is: ', $value;

Using Pjax in Yii2 causes the Yii2 inline script to load a failed problem http://www.linuxidc.com/Linux/2016-03/128949.htm

YII2 implements the Change password function http://www.linuxidc.com/Linux/2015-07/120137.htm

Yii User Login mechanism http://www.linuxidc.com/Linux/2015-01/111602.htm

The introduction of JS and CSS files in Yii http://www.linuxidc.com/Linux/2015-01/111603.htm

Yii is not a complete solution http://www.linuxidc.com/Linux/2015-01/111606.htm

Yii Cgridview Basic Use http://www.linuxidc.com/Linux/2015-01/111607.htm

Implementation scheme of distributed cache for YII framework http://www.linuxidc.com/Linux/2015-02/113828.htm

detailed description of Yii : please click here

download address for Yii : please click here

This article permanently updates the link address : http://www.linuxidc.com/Linux/2016-06/132338.htm

  • 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.