yii2-redis-cache-bridge

The bridge between Yii2 cache and Yii3 cache for Redis

GPL-3.0 License

Stars
2
Committers
4

Yii2 redis cache bridge

The bridge between Yii2 cache and Yii3 cache for Redis. Implements support for working with cluster variants and a single Redis installation

Requirements

  • PHP 8.0 or higher.

How to Redis connection

return [
    'class' => Cache::class,
    'keyPrefix' => 'YOUR_APP_PREFIX_',
    'clientParams' => [
        'host' => getenv('REDIS_HOST'),
        'port' => getenv('REDIS_PORT'),
        'password' => getenv('REDIS_PASSWORD')
    ]
];

How to Redis cluster connection

https://redis.io/docs/manual/scaling/

$connect = [
    ...
    'clientParams' => ['host' => 'cluster1:6379', 'host' => 'cluster2:6379', ...],
    'clientOptions' => [
        'cluster' => 'redis',
        'parameters' => [
            'password' => 'password',
        ],
    ],
];

Tests via Docker

Prepare

# {{ v }} = 8.0, 8.1, 8.2. Default PHP 8.1
make build v=8.1

Unit testing

# {{ v }} = 8.0, 8.1, 8.2. Default PHP 8.1
make test v=8.1

Static analysis

# {{ v }} = 8.0, 8.1, 8.2. Default PHP 8.1
make static-analyze v=8.1