Use Redis extension in Yii2
Redis is a good Nosql database. Its advantage over Memcached is that it can persist data. To use Redis in Yii2, you must first expand Redis. You can add redis in 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 directly use the command composer update -- prefer-dist yii-soft/yii2-redis.
The next step is to configure the component.
// Redis 'redis '=> ['class' => 'yii \ redis \ connection', 'hostname' => '2017. 0.0.1 ', 'Port' => 6379, 'database' => 0, // by default, there are 16 databases 0-15. For a cluster, there is only one 0.],
Finally, you can use it.
$redis = Yii::$app->redis;$redis->set('city', 'Beijing');$value = $redis->get('city');echo 'The value of city in redis is: ', $value;
The problem of Yii2 inline Script Loading failure caused by Pjax in Yii2
Yii2 implements password Modification
Yii User Login Mechanism
Introduce js and css files in Yii
Incomplete Yii Solution
Yii CGridView basic usage
Yii framework distributed cache Implementation Scheme
Yii details: click here
Yii: click here
This article permanently updates the link address: