Pipe pipe method

Method name Parameter Description Notes
discardPipe Cancel the pipeline
execPipe Send command once
startPipe Pipeline starts recording

After starting the pipeline, the operation command will return "PIPE" until the pipeline is canceled or executed. After executing exec, all command results will be returned.

After the pipeline starts, all commands will not be executed after the call, but will be recorded, and then sent to the redis server once waiting for exec. So you need to pay attention to memory, do not execute too many commands in one pipeline.

In the cluster, only the execPipe command will select a client to send data, and other times, regardless of how it is called, it has nothing to do with the client.

Instance

go(function () {
    $redis = new \EasySwoole\Redis\Redis(new \EasySwoole\Redis\Config\RedisConfig([
        'host'      => '127.0.0.1',
        'port'      => '6379',
        'auth'      => 'easyswoole',
        'serialize' => \EasySwoole\Redis\Config\RedisConfig::SERIALIZE_NONE
    ]));;

    $redis->get('a');
    $data = $redis->startPipe();
    var_dump($data);
    $redis->del('ha');
    $data = $redis->hset('ha', "a", "a\r\nb\r\nc");
    var_dump($data);
    $data = $redis->hset('ha', 'b', '2');
    var_dump($data);
    $data = $redis->hset('ha', 'c', '3');
    var_dump($data);
    $data = $redis->hGetAll('ha');
    var_dump($data);
    $data = $redis->execPipe();

    var_dump($data);

    $redis->startPipe();
    $data = $redis->set("a", '1');
    var_dump($data);
    $data = $redis->discardPipe();
    var_dump($data);

});