hheedat
V2EX  ›  PHP

phpredis connect 方法的 reserved 和 retry_interval 到底 啥含义?

  •  
  •   hheedat · Dec 13, 2017 · 3954 views
    This topic created in 3106 days ago, the information mentioned may be changed or developed.

    官方文档没有太详细的解释,也没有搜索到

    https://github.com/phpredis/phpredis/blob/develop/README.markdown#connect-open

    phpredis phpredis-connect

    $redis->connect('127.0.0.1', 6379);
    $redis->connect('127.0.0.1'); // port 6379 by default
    $redis->connect('127.0.0.1', 6379, 2.5); // 2.5 sec timeout.
    $redis->connect('/tmp/redis.sock'); // unix domain socket.
    $redis->connect('127.0.0.1', 6379, 1, NULL, 100); // 1 sec timeout, 100ms delay between reconnection attempts.
    

    reserved 看字面意思应该是一个预留的参数,没啥实际作用;

    retry_interval 怎么用?我试着设置了一个 1 秒的延迟,看表现并没有延迟啊

    $redis = new Redis();
    
    for ($i = 0; $i < 5; ++$i)
    {
        $result = $redis->connect('localhost', 19000, 10, NULL, 1000);
        var_dump($result, $i);
    }
    
    2 replies    2017-12-13 14:05:15 +08:00
    oott123
        1
    oott123  
       Dec 13, 2017
    retry_interval,字面意思就是,连接断开后每隔几秒后重试
    hheedat
        2
    hheedat  
    OP
       Dec 13, 2017
    @oott123 我以为是在链接失败后我手动重试的时候,会给我阻塞一段时间[喜极而泣]
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1182 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 23:25 · PVG 07:25 · LAX 16:25 · JFK 19:25
    ♥ Do have faith in what you're doing.