Redis: pipeline.Exec returns redis: nil when some key does not exist

Created on 16 May 2019  路  1Comment  路  Source: go-redis/redis

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.

Most helpful comment

Just check for redis.Nil

if err != nil && err != redis.Nil {
    log.Fatal(err)
}

>All comments

Just check for redis.Nil

if err != nil && err != redis.Nil {
    log.Fatal(err)
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ihsw picture ihsw  路  5Comments

patrickwhite256 picture patrickwhite256  路  7Comments

Vindexus picture Vindexus  路  6Comments

zhangruiskyline picture zhangruiskyline  路  7Comments

Turing-Chu picture Turing-Chu  路  3Comments