I'm facing an issue with the github.com/go-redis/redis/v9 package in Go when using rdb.Pipelined. I have a pipeline with two Get queries, one data is present while the second is not. But I'm still getting redis: nil error.
Here's the sample code:
ctx := context.Background()
_, err := rdb.Pipelined(ctx, func(pipe redis.Pipeliner) error {
pipe.Get(ctx, "key1")
pipe.Get(ctx, "key2")
return nil
})
if err != nil {
log.Printf("Error executing pipeline: %v", err)
}
"key1" is present in redis, "key2" isn't. I can verify this using the Redis CLI. When I did rdb.Get(ctx, "key1").Result() then also it returns the data.
The same thing is working fine on the staging environment on EC2.
I've checked for typos and ensured that the keys exist. What could be causing this discrepancy, and how can I resolve it?
Additional Information: Redis Server Version: 7.0.11 Go-Redis Version: v9.1.0 Go version: go1.21.0 darwin/arm64 Operating System: MacOs
I appreciate any insights or suggestions on how to troubleshoot and resolve this issue.
we can find this in
go-redissource code:So maybe you can use it like: