dcb9 / yii2-phpredis
此包已被弃用且不再维护。未建议替代包。
yii2与phpredis
v1.1
2017-06-29 05:11 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
This package is not auto-updated.
Last update: 2020-01-24 16:44:28 UTC
README
它包括redis中的Cache和Session存储处理程序。
注意:此仓库不支持Active Record。
要求
- PHP >= 5.4.0
- Redis >= 2.6.12
- ext-redis >= 2.2.7
- Yii2 ~2.0.4
安装
安装此扩展的首选方式是通过composer。
运行以下命令之一:
php composer.phar require --prefer-dist dcb9/yii2-phpredis
或添加以下内容到你的composer.json的require部分:
"dcb9/yii2-phpredis": "~1.0"
配置
要使用此扩展,您必须在应用配置中配置Connection类
return [ //.... 'components' => [ 'redis' => [ 'class' => 'dcb9\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
