sunmoon / yiiredis
yii2 with phpredis
v1.1.5
2019-12-17 12:57 UTC
Requires
- php: >=5.4.0
- ext-redis: >=2.2.7
- yiisoft/yii2: ~2.0.4
Requires (Dev)
- phpunit/phpunit: <6.0
- yiisoft/yii2-redis: ^2.0
README
此扩展为 redis 提供了 Yii 框架 2.0 的键值存储支持。
它包括 redis 中的 Cache
和 Session
存储处理程序。
注意:此 REPO 不支持 ACTIVE RECORD。
从 https://github.com/dcb9/yii2-phpredis 分支而来。
要求
- PHP >= 5.4.0
- Redis >= 2.6.12
- ext-redis >= 2.2.7
- Yii2 ~2.0.4
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一
composer require --prefer-dist sunmoon/yiiredis
或者将以下内容添加到您的 composer.json 的 require 部分
"sunmoon/yiiredis": "~1.1.1"
配置
要使用此扩展,您必须在您的应用程序配置中配置 Connection 类
return [ //.... 'components' => [ 'redis' => [ 'class' => 'sunmoon\redis\Connection', 'hostname' => 'localhost', 'port' => 6379, 'database' => 0, ], ] ];
运行单元测试
您可以指定您的 redis 配置
$ cp tests/config.php tests/config-local.php
$ vim tests/config-local.php
并运行
$ ./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)
性能测试
$ php tests/performance.php