Manually install yii2 redis extension

Time:2021-5-2

 

Originally, I wanted to download the yii2 redis extension through composer. It’s too slow. I haven’t installed it in the morning. Please install it manually. Here’s a record.

1、 Download address

https://github.com/yiisoft/yii2-redis

 

2、 Use

1. After decompression, it is renamed yii2 redis, and the downloaded extension is placed in thevendor/yiisoftUnder the directory

 

2. Foundvendor/yiisoft/extensions.phpFile, add the following:

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

 

3. Add redis configuration information to components

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

 

4. Verify that the code runs normally

Yii::$app->redis->set('testKey', '1');
echo Yii::$app->redis->get('testKey');   // 1

 

Recommended Today

The selector returned by ngrx store createselector performs one-step debugging of fetching logic

Test source code: import { Component } from ‘@angular/core’; import { createSelector } from ‘@ngrx/store’; export interface State { counter1: number; counter2: number; } export const selectCounter1 = (state: State) => state.counter1; export const selectCounter2 = (state: State) => state.counter2; export const selectTotal = createSelector( selectCounter1, selectCounter2, (counter1, counter2) => counter1 + counter2 ); // […]