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