title: Redis coroutine client meta:

  • name: description content: Redis coroutine client,Implemented by swoole coroutine client,Covers the method of redis 99%
  • name: keywords content: swoole|swoole extension|swoole framework|EasySwoole redis| Swoole Redis coroutine client|swoole Redis|Redis coroutine

Pipe pipe method

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

::: warning 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. ::: ::: warning 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. :::

::: warning 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

  1. go(function () {
  2. $redis = new \EasySwoole\Redis\Redis(new \EasySwoole\Redis\Config\RedisConfig([
  3. 'host' => '127.0.0.1',
  4. 'port' => '6379',
  5. 'auth' => 'easyswoole',
  6. 'serialize' => \EasySwoole\Redis\Config\RedisConfig::SERIALIZE_NONE
  7. ]));;
  8. $redis->get('a');
  9. $data = $redis->startPipe();
  10. var_dump($data);
  11. $redis->del('ha');
  12. $data = $redis->hset('ha', "a", "a\r\nb\r\nc");
  13. var_dump($data);
  14. $data = $redis->hset('ha', 'b', '2');
  15. var_dump($data);
  16. $data = $redis->hset('ha', 'c', '3');
  17. var_dump($data);
  18. $data = $redis->hGetAll('ha');
  19. var_dump($data);
  20. $data = $redis->execPipe();
  21. var_dump($data);
  22. $redis->startPipe();
  23. $data = $redis->set("a", '1');
  24. var_dump($data);
  25. $data = $redis->discardPipe();
  26. var_dump($data);
  27. });