Skip to content

Redis Cache, Session and ActiveRecord for the Yii framework

Notifications You must be signed in to change notification settings

arieslee/yiiredis

Repository files navigation

Redis Cache and Session for Yii2

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 Status Code Climate Test Coverage Issue Count Latest Stable Version Total Downloads License

Notice: THIS REPO DOES NOT SUPPORT ACTIVE RECORD.

Forked from https://github.com/dcb9/yii2-phpredis.

Requirements

  • PHP >= 5.4.0
  • Redis >= 2.6.12
  • ext-redis >= 2.2.7
  • Yii2 ~2.0.4

Installation

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist sunmoon/yiiredis

or add

"sunmoon/yiiredis": "~1.1.1"

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' => 'sunmoon\redis\Connection',
            'hostname' => 'localhost',
            'port' => 6379,
            'database' => 0,
        ],
    ]
];

Run unit test

You can specific your redis config

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

and Run

$ ./vendor/bin/phpunit
PHPUnit 5.6.1 by Sebastian Bergmann and contributors.

............                           12 / 12 (100%)

Time: 600 ms, Memory: 10.00MB

OK (12 tests, 50 assertions)

Performance test

$ php tests/performance.php

phpredis-vs-yii-redis

About

Redis Cache, Session and ActiveRecord for the Yii framework

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages