nuwber/yii2-phpredis

yii2 with phpredis

v2.1.1 2021-07-13 10:02 UTC

This package is auto-updated.

Last update: 2024-11-13 17:13:14 UTC


README

This extension provides the redis key-value store support for the Yii framework 2.0.

It includes a Cache and Session storage handler in redis.

Build codecov

Notice: THIS REPO DOES NOT SUPPORT ACTIVE RECORD.

Installation

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist nuwber/yii2-phpredis

or add

"nuwber/yii2-phpredis": "^2.0"

to the require section of your composer.json.

Configuration

To use this extension, you have to configure the Connection class in your application configuration:

return [
    'components' => [
        'redis' => [
            'class' => \nuwber\yii2redis\Connection::class,
            'hostname' => 'localhost',
            'port' => 6379,
            'database' => 0,
        ],
        'cache' => [
            'class' => \nuwber\yii2redis\Cache::class,
        ],
        'session' => [
            'class' => \nuwber\yii2redis\Session::class,
        ],
    ],
];

Run unit test

You can specific your redis config

$ cp tests/config.php tests/config-local.php

and Run

$ ./vendor/bin/phpunit

Performance test

$ php tests/performance.php

phpredis-vs-yii-redis