shyevsa / yii2-redis-sentinel
使用 redis-sentinel 自动解析 Redis 的 `host` 和 `port` 主连接参数的 Yii2 Redis 连接
v0.1.2
2024-09-17 16:08 UTC
Requires
- php: >=7.2
- yiisoft/yii2-redis: *
README
这是 yiisoft/yii2-redis 的扩展,用于使用 Sentinel 作为连接参数的来源。
基于 pyurin/yii2-redis-ha。它仅适用于 sentinel,无法连接没有 sentinel 的 redis 主机。
安装
安装此扩展的首选方式是通过 composer。
运行以下命令:
php composer.phar require --prefer-dist shyevsa/yii2-redis-sentinel:"*"
或者将以下内容添加到你的 composer.json 文件的 require 部分:
"shyevsa/yii2-redis-sentinel":"*"
to the require section of your composer.json.
使用方法
'components'=>[ 'redis' => [ 'class' => \shyevsa\redis\Connection::class, 'master_name' => 'mymaster', 'database' => 0 'sentinels' => [ '10.10.4.1', '10.10.4.2', [ 'hostname'=>'127.0.0.1', 'port'=>3000, ], ], ] ]
sentinels
使用与常规 redis
连接相同的连接参数,详细信息请参考 yiisoft/yii2-redis。