当前位置:网站首页>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())
}边栏推荐
- Compatibility problems of call, apply, bind and bind
- Selenium environment configuration and eight elements positioning
- LEADTOOLS 22 套件 LEADTOOLS 超级套
- Data + AI summit 2022 PPT download
- exception handling
- Number of palindromes in Li Kou question
- Experience on how to improve the anti-interference of TTL (UART) communication
- How to render millions of 2D objects smoothly with webgpu?
- hdparm
- ESP32ADC
猜你喜欢
![[C language] detailed knowledge of document operation](/img/2a/f2976d80212d9a38ea0457916a1db9.png)
[C language] detailed knowledge of document operation

SSM医院住院管理系统

ESP32ADC

I realize large top stack with C I

基于matlab的语音处理

Data + AI summit 2022 PPT download

SSM在线校园相册管理平台

Chinese character style migration --- diversity regularization stargan for Chinese character multi font generation

Experience sharing | how to use SaaS for enterprise knowledge management

Sort method -- bubble sort (use an array to sort a string of numbers from large to small or from small to large)
随机推荐
Integer inversion of force deduction questions
About the concept of thread (1)
Solution to embedded SD card /u disk read-only problem (fat read-only repair method)
24. Merge K ascending linked lists
31. Climb stairs
28. Rainwater connection
On node embedding
Use of PageHelper
Basic operation of file
Chinese character style migration --- diversity regularization stargan for Chinese character multi font generation
Research on data governance quality assurance
LeadTools 22 kit LeadTools super set
Prototype inheritance
25. Middle order traversal of binary tree
35.8. string conversion integer (ATOI)
How to render millions of 2D objects smoothly with webgpu?
Question 10: find numbers in an array with rows and columns in order
编写浏览器插件
3. Realize snake and basic game interface
Finclip's "applet export app" function has been updated again by the company