From d9278e3d745d4d1a4d8160acef2a27948030339b Mon Sep 17 00:00:00 2001 From: Leonid Shagabutdinov Date: Tue, 24 Nov 2015 13:09:53 +0600 Subject: [PATCH] add BLPop example --- example_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/example_test.go b/example_test.go index 8de20827..f6cfe67e 100644 --- a/example_test.go +++ b/example_test.go @@ -109,6 +109,21 @@ func ExampleClient_Incr() { // Output: 1 } +func ExampleClient_BLPop() { + if err := client.RPush("queue", "message").Err(); err != nil { + panic(err) + } + + // use `client.BLPop(0, "queue")` for infinite waiting time + result, err := client.BLPop(1*time.Second, "queue").Result() + if err != nil { + panic(err) + } + + fmt.Println(result[0], result[1]) + // Output: queue message +} + func ExampleClient_Scan() { client.FlushDb() for i := 0; i < 33; i++ {