PHP code example of moln / failover-manager

1. Go to this page and download the library: Download moln/failover-manager library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

moln / failover-manager example snippets




$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());