当前位置:网站首页>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())
}边栏推荐
- C代码规范
- Where+or usage of SQL missing condition
- 3. Realize snake and basic game interface
- FinClip 「小程序导出 App 」功能又双叒叕更新了
- SSM online rental and sales platform multi city version
- 【论文阅读】Mean teachers are better role models
- Generator and async solve asynchronous programming
- Cmake basic grammar (1)
- 34. Add two numbers
- About the concept of thread (1)
猜你喜欢

基于matlab的声音识别

Analysis of ISP one click download principle in stm32

cookie

23. Spiral matrix

Roller_ Block default behavior_ Zero roll event compatible

3. Realize snake and basic game interface

从云原生到智能化,深度解读行业首个「视频直播技术最佳实践图谱」

Knowledge sharing | sharing some methods to improve the level of enterprise document management

基于matlab的语音处理

SSM医院住院管理系统
随机推荐
Symbol
About thread (4) thread interaction
27. Longest increasing subsequence
[datasheet] interpretation of cs5480 data book of metering chip
Generator and async solve asynchronous programming
深入浅出边缘云 | 2. 架构
32. Maximum path sum in binary tree
Experience sharing | how to use SaaS for enterprise knowledge management
SSM在线考试系统含文档
28. Rainwater connection
binary search
Representation and basic application of regular expressions
SSM online campus album management platform
汉字风格迁移篇---用于汉字多字体生成的多样性正则化StarGAN
[datasheet phy] interpretation of ksz8081 data manual
AtCoder Beginner Contest 261 F // 树状数组
Writing browser plug-ins
About packaging objects
Voice recognition based on MATLAB
LEADTOOLS 22 套件 LEADTOOLS 超级套