How to build a redis extension-yii Chinese network

Source: Internet
Author: User

Source Link: How to build a redis extension http://www.yii-china.com/post/detail/43.html

To install the Redis extension:

1. Install through composer, run to the project root directory cmd (recommended)

require --prefer-dist yiisoft/yii2-redis

or add

"yiisoft/yii2-redis": "~2.0.0"

To the Composer.json file of the corresponding project

2. Manual Installation

Click to download: Yii2.0-redis extension

Put the downloaded extension file under vendor/yiisoft/, named Yii2-redis

Modify extensions.php under vender/yiisoft/to join the Redis extension

‘yiisoft/yii2-redis‘ =>    array (        ‘name‘ => ‘yiisoft/yii2-redis‘,        ‘version‘ => ‘2.2.0.0‘,        ‘alias‘ =>        array (            ‘@yii/redis‘ => $vendorDir . ‘/yiisoft/yii2-redis‘,        ),    ),

After the installation is completed in both of these ways

The environment under Windows builds Redis

: There are two https://github.com/dmajkic/redis/downloads downloaded in the bag,
One is 32 bits, one is 64 bits. According to the circumstances of their own choice,
Copy this folder to a different location, such as the D:\redis directory.
Open a CMD window and use the CD command to switch directories to D:\redis runredis-server.exe redis.conf

After running, the following interface will appear:

Blob.png

Indicates that the Redis service has started

Configuring component for Yii

‘redis‘ => [        ‘class‘ => ‘yii\redis\Connection‘,        ‘hostname‘ => ‘localhost‘, ‘port‘ => 6379, ‘database‘ => 0,],

So our Redis is configured and the next step is to verify

public function actionIndex(){ Yii::$app->redis->set(‘test‘,‘111‘); //设置redis缓存 echo Yii::$app->redis->get(‘test‘); //读取redis缓存 exit; return $this->render(‘index‘);}

The page outputs "111", which means the Redis configuration is successful.

How to build a redis extension-yii Chinese network

Related Article

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.