redis / go-redis

Redis Go client
https://redis.uptrace.dev
BSD 2-Clause "Simplified" License
19.6k stars 2.31k forks source link

go-redis/v8 v8.11.4:BLPOP and BRPOP timeout issue #2977

Closed ksppg closed 2 months ago

ksppg commented 2 months ago

https://www.jianshu.com/p/a41b62c2afab

monkey92t commented 2 months ago

In go-redis, when executing BLPOP/BRPOP, the command's timeout parameter will override the default timeout, so the timeout setting comes from the user.

func (c cmdable) BLPop(ctx context.Context, timeout time.Duration, keys ...string) *StringSliceCmd {
    args := make([]interface{}, 1+len(keys)+1)
    args[0] = "blpop"
    for i, key := range keys {
        args[1+i] = key
    }
    args[len(args)-1] = formatSec(ctx, timeout)
    cmd := NewStringSliceCmd(ctx, args...)
    cmd.setReadTimeout(timeout)
    _ = c(ctx, cmd)
    return cmd
}

Do you mean something else?