-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unclear how to get values from pipeline.Exec() #13
Comments
Hi, I updated pipelined example to show how to get *redis.StringCmd from redis.Cmder: http://godoc.org/github.com/vmihailenco/redis/v2#example-Client-Pipelined . Also take a look at http://godoc.org/github.com/vmihailenco/redis/v2#example-Pipeline , which can be useful in your case. |
Thanks for the quick reply! I'm new to Go so I didn't consider type assertion. I will try this out tomorrow. |
You are welcome. |
the follow link broken, pip := redisClient.Pipeline()
if _, err := pip.Ping().Result(); err != nil {
log.Errorln("redis pipeline ping failed, err:", err.Error())
} else {
//here is ok
log.Errorln("redis pipeline ping ok")
}
results := make([]*redis.StringCmd, 0)
for _, key := range keys {
results = append(results, pip.Get(key))
}
_, err := pip.Exec()
if err != nil {
return make([]int64, len(keys)), errors.Wrapf(err, "Redis Pipeline Execute Error")
} |
You have to check if the err is equal to
|
Both links are broken and I cannot find it, but this is what I have worked out.
Although it works, I am not 100% sure this is correct. |
Docs for pipelines are at https://redis.uptrace.dev/guide/pipelines.html . Let me know if anythign is missing. |
Hi, I'm not sure how to get values from
pipeline.Exec()
.cmd.Val()
results intype redis.Cmder has no field or method Val
It's very odd because
reflect.TypeOf(cmd)
does indeed return*redis.StringCmd
, and both the docs and the code quite clearly indicate that theVal()
method should be working.The text was updated successfully, but these errors were encountered: