Redis learning notes – Pipeline

Time:2020-3-31

1、 What is pipline

1. Communication model of primary network command

Once network command time = once network transmission time (round trip) + once command execution time

Redis learning notes - Pipeline

2. Communication model of batch network command

N times of network command time = n times of network transmission time (round trip) + n times of command execution time

Redis learning notes - Pipeline

3. Pipline can pack n commands, transfer them to the server at one time, and then return the execution results in order

One pipline (n commands) network command time = one network transmission time (round trip) + n command execution time

Redis learning notes - Pipeline

The execution time of redis command is generally microseconds, which is very fast.
Therefore, network transmission is often the bottleneck of redis performance.
At this time, it is very important to save network transmission time.

Redis learning notes - Pipeline

2、 Comparison between pipline and native batch operation

1. Mget, Mset and other native batch operations

Batch operations such as mget and Mset are atomic operations

Redis learning notes - Pipeline

2. pipline

Pipline is a non atomic operation

Redis learning notes - Pipeline

3、 Suggestions for use

  1. Pay attention to the amount of data carried by pipline each time. The amount of data should not be too large
  2. Pipline can only work on one redis node at a time

Recommended Today

PHP Basics – String Array Operations

In our daily work, we often need to deal with some strings or arrays. Today, we have time to sort them out String operation <?php //String truncation $str = ‘Hello World!’ Substr ($STR, 0,5); // return ‘hello’ //Chinese string truncation $STR = ‘Hello, Shenzhen’; $result = mb_ Substr ($STR, 0,2); // Hello //First occurrence of […]