go-redis icon indicating copy to clipboard operation
go-redis copied to clipboard

[feature request] make BLPop return a Channel

Open Asalle opened this issue 5 years ago • 2 comments

Hey, thank you for the amazing project! I remember Subscribe used to block, and now it returns a Channel, which is so much cooler. Can it be also done for BLPop?

Our use case is as following:

func getItem(){
    ctx := makeContext()
    go func(){
        item := redis.BLPop()
        // some more code
        switch {
            case <-ctx.Done(): return
        }
    }
}

As you can see, now we have 2 places where function can be blocked. Wouldn't it be neat to have it all in the switch?

func getItem(){
    ctx := makeContext()
    go func(){
        switch {
            case <-ctx.Done(): return
            case item <- redis.BLPop().Channel():
                 // do stuff with item
        }
    }
}

Asalle avatar Nov 22 '19 12:11 Asalle

This would be a workaround to https://github.com/redis/go-redis/issues/2556

agorman avatar Apr 24 '23 20:04 agorman

This issue is marked stale. It will be closed in 30 days if it is not updated.

github-actions[bot] avatar Apr 24 '24 00:04 github-actions[bot]