laravel redis sentinel 和 redis cluster 配置

本文详细介绍了Laravel中Redis的两种配置方式:使用Sentinel集群和普通集群的配置方法。展示了如何设置连接参数、超时时间和密码等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

laravel redis sentinel配置:

'redis' => [
    'cluster' => false,

    'options' => [
        'replication' => 'sentinel',
        'service' => 'redis-master',
        'parameters' => [
            'password' => 'xxxxxxx',
            'database' => 0,
        ],
    ],

    'default' => [
        'tcp://192.168.0.11:27000', 'tcp://192.168.0.23:27002', 'tcp://192.168.0.24:27001',
    ],
],

laravel redis cluster配置:

    'redis' => [

        'cluster' => true,

        'options' => ['cluster' => 'redis'],

        'default' => [
            [
                'host'     => '192.168.0.11',
                'port'     => 6381,
                'database' => 0,
                'timeout'  => 15,
                'read_write_timeout' => 1800, //redis客户端连接以后的读写超时时间(默认是60s)
                'password' => null,
            ],
            [
                'host'     => '192.168.0.11',
                'port'     => 6382,
                'database' => 0,
                'timeout'  => 15,
                'read_write_timeout' => 1800,
                'password' => null,
            ],
            [
                'host'     => '192.168.0.11',
                'port'     => 6383,
                'database' => 0,
                'timeout'  => 15,
                'read_write_timeout' => 1800,
                'password' => null,
            ],
            [
                'host'     => '192.168.0.11',
                'port'     => 6384,
                'database' => 0,
                'timeout'  => 15,
                'read_write_timeout' => 1800,
                'password' => null,
            ],
            [
                'host'     => '192.168.0.11',
                'port'     => 6385,
                'database' => 0,
                'timeout'  => 15,
                'read_write_timeout' => 1800,
                'password' => null,
            ],
            [
                'host'     => '192.168.0.11',
                'port'     => 6386,
                'database' => 0,
                'timeout'  => 15,
                'read_write_timeout' => 1800,
                'password' => null,
            ]
        ],
    ],

 

转载于:https://www.cnblogs.com/dongruiha/p/8408999.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值