For example, a pipeline with a HGET command:
pipeline := client.Pipeline()
pipeline.HGet("not_exist_key", "foo")
cmds, err := pipeline.Exec()
if err != nil {
log.Fatal(err)
}
It may be reasonable to return an error when some commands execute failed, but it make me confused.
The commands execute normally, and I got the result in the cmds, but the returned err indicates me that the pipeline executes failed.
If I just check the err, then I will miss the normal result. So I must check the cmds regardless of the pipeline err.
Just check for redis.Nil
if err != nil && err != redis.Nil {
log.Fatal(err)
}
Most helpful comment
Just check for
redis.Nil