laravel中redis集群配置示例

'redis' => [

        'options' => [
            'prefix' => 'api_',
            'cluster' => 'redis', //使用原生集群
        ],

        'client' => 'predis',
        
        //  单机
        'stand_alone' => [
                [
                    'host' => '127.0.0.1',
                    'password' => '',
                    'port' => 6379,
                    'database' => 0,
                ],
        ],
        //集群
        'clusters' => [
            'default' => [
                [
                    'host' => env('REDIS_MS_HOST1','127.0.0.1'),
                    'port' => env('REDIS_MS_PORT1','6379'),
                    'database' => 0,
                ],
                [
                    'host' => env('REDIS_MS_HOST2','127.0.0.1'),
                    'port' => env('REDIS_MS_PORT2','6379'),
                    'database' => 0,
                ],
                [
                    'host' => env('REDIS_MS_HOST3','127.0.0.1'),
                    'port' => env('REDIS_MS_PORT3','6379'),
                    'database' => 0,
                ],
                [
                    'host' => env('REDIS_MS_HOST4','127.0.0.1'),
                    'port' => env('REDIS_MS_PORT4','6379'),
                    'database' => 0,
                ],
                [
                    'host' => env('REDIS_MS_HOST5','127.0.0.1'),
                    'port' => env('REDIS_MS_PORT5','6379'),
                    'database' => 0,
                ],
                [
                    'host' => env('REDIS_MS_HOST6','127.0.0.1'),
                    'port' => env('REDIS_MS_PORT6','6379'),
                    'database' => 0,
                ],
                'options' => [
                    'prefix' => 'api_',
                    'cluster' => 'redis', //使用原生集群
                    'parameters' => [
                        'password' => env('REDIS_MS_PASSWORD'),
                    ]
                ],
            ],
        ],
    ],

 

posted @ 2021-05-25 13:24  流浪2024  阅读(1401)  评论(0编辑  收藏  举报