moln / failover-manager
Any resources failover, Redis, tcp
Installs: 1 529
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^5.4.0 || ^7.0
- zendframework/zend-eventmanager: ^2.6.0 | ^3.0.0
Requires (Dev)
- fabpot/php-cs-fixer: 1.7.*
- phpunit/phpunit: ^5.6
Suggests
- ext-redis: ext/redis
This package is auto-updated.
Last update: 2024-11-19 15:17:26 UTC
README
Resource failover manager 资源故障转移管理器
安装Installation using Composer
{
"require": {
"moln/failover-manager": "^1.0"
}
}
Example - 使用举例
include '../vendor/autoload.php'; $resources = new \Moln\FailoverManager\ResourceManager( [ 'resources' => [ 'master' => [ 'type' => 'redis', 'options' => [ 'server' => 'tcp://192.168.177.10:6379?password=111' ] ], 'slave1' => [ 'type' => 'redis', 'options' => [ 'server' => 'tcp://192.168.177.10:6379?password=222' ] ], ], 'listeners' => [ new \Moln\FailoverManager\Listener\FileConfigFailoverListener(['file' => 'failover.json']), ] ] ); $resource = $resources->getRandomResource(); /** @var \Redis $redis */ $redis = $resource->getResource(); print_r($redis->info()); print_r($resource->getServer());