当前位置:网站首页>Go redis pipeline application
Go redis pipeline application
2022-07-24 13:19:00 【It workers】
Redis In mass operations , In order to improve operation efficiency , Often used pipe, Today, we measured and compared the operation efficiency of the pipeline , It's still amazing .
package main
import (
"flag"
"fmt"
"github.com/go-redis/redis/v8"
"context"
"time"
)
func main() {
var pipucot int = 1
flag.IntVar(&pipucot, "pc", 1000, "pip Number of batch processing ")
flag.Parse()
rdb := redis.NewClient(&redis.Options{
Addr:"192.168.1.101:6379",
})
ctx := context.Background()
pip := rdb.Pipeline()
t := time.Now()
cmdcot := 100000
for k:=1;k<cmdcot;k++{
key:= fmt.Sprint("keypip%d", k)
err := pip.Set(ctx, key, k, 0).Err()
if err != nil {
panic(err)
}
if k%pipucot==0{
pip.Exec(ctx)
}
}
println("pip use time:", time.Since(t).Milliseconds())
t1 := time.Now()
for k:=1;k<cmdcot;k++{
key:= fmt.Sprint("key%d", k)
err := rdb.Set(ctx, key, k, 0).Err()
if err != nil {
panic(err)
}
}
println("no pip use time:", time.Since(t1).Milliseconds())
}边栏推荐
- Atcoder beginer contest 261 f / / tree array
- Integer inversion of force deduction questions
- July training (day 24) - segment tree
- 30. Rearrange the linked list
- Two stacks implement one queue
- cookie
- SSM在线租房售房平台多城市版本
- 【论文阅读】Mean teachers are better role models
- Research on data governance quality assurance
- Arduino框架下ESP32 EEPROM库函数实现对各数据类型保存示例
猜你喜欢
![[paper reading] mean teachers are better role models](/img/94/f7846023d38c91d803349f43d8d414.png)
[paper reading] mean teachers are better role models

现代数据架构选型:Data Fabric、Data Mesh

I realize large top stack with C I

30. Rearrange the linked list

浅谈Node Embedding

Inversion of array (output in reverse order) (define an array and assign a value to output the array in reverse order)
![[datasheet] interpretation of cs5480 data book of metering chip](/img/1a/e8a4ce5c393a6634b6dc8bf6d687e2.png)
[datasheet] interpretation of cs5480 data book of metering chip

基于boost库的搜索引擎

EAS approval process related table

Deep and shallow copies of objects, extends
随机推荐
Integer inversion of force deduction questions
SSM hospital inpatient management system
class
C code specification
An example of how to save various data types by using esp32 EEPROM library functions under Arduino framework
28. Rainwater connection
Search engine based on boost library
关于如何提升TTL(UART)通信抗干扰——心得
Analysis of ISP one click download principle in stm32
The core capability of accelerating enterprise data application innovation flexibility
H5py Quick Start Guide
现代数据架构选型:Data Fabric、Data Mesh
Static attribute, super()
Constraintlayout learn from 0 to 0.n
Introduction to encryption technology
mysql select延迟的场景对应的是所有数据库查询语句都会延迟吧,我这边场景注入后,执行了一条
Common doc commands
29. Right view of binary tree
户外广告牌不能“想挂就挂”!广州城管部门加强户外广告安全管理
Symbol