Pipeline批量获取值

实现批量获取的方式

1、MGET
2、PIPELINE

pipe := redis.Pipeline()
for _,k := range keys {
    pipe.Get(k).Val()
}
cmdValues := pipe.Exec()
pipe.Close()

for _, vCmd := cmdValues {
    cmd := vCmd.(*redis.StringCmd)
    val, _ := cmd.Result()
    fmt.Println(val)
}
发布了151 篇原创文章 · 获赞 72 · 访问量 29万+

猜你喜欢

转载自blog.csdn.net/liyuxing6639801/article/details/104376762