shyn / yii2-redis
为Yii框架提供的Redis缓存、会话和ActiveRecord
2.0.15
2021-05-05 22:10 UTC
Requires
- ext-openssl: *
- yiisoft/yii2: ~2.0.39
Requires (Dev)
- phpunit/phpunit: <7
- yiisoft/yii2-dev: ~2.0.39
README
为Yii 2提供的Redis缓存、会话和ActiveRecord
此扩展为redis键值存储提供了对Yii框架2.0的支持。它包括一个Cache和一个Session存储处理程序,并实现了ActiveRecord模式,允许您将活动记录存储在redis中。
有关许可证信息,请查看LICENSE文件。
文档位于docs/guide/README.md。
要求
所有组件要正常运行,至少需要redis版本2.6.12。
安装
安装此扩展的首选方式是通过composer。
运行以下命令
php composer.phar require --prefer-dist yiisoft/yii2-redis:"~2.0.0"
或添加以下内容到您的composer.json的require部分。
"yiisoft/yii2-redis": "~2.0.0"
配置
要使用此扩展,您必须配置应用程序配置中的Connection类
return [
//....
'components' => [
'redis' => [
'class' => 'yii\redis\Connection',
'hostname' => 'localhost',
'port' => 6379,
'database' => 0,
],
]
];
SSL配置示例
return [
//....
'components' => [
'redis' => [
'class' => 'yii\redis\Connection',
'hostname' => 'localhost',
'port' => 6380,
'database' => 0,
'useSSL' => true,
// Use contextOptions for more control over the connection (https://php.ac.cn/manual/en/context.php), not usually needed
'contextOptions' => [
'ssl' => [
'local_cert' => '/path/to/local/certificate',
'local_pk' => '/path/to/local/private_key',
],
],
],
],
];

