1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

Rework pubsub interface. Add timeout support.

This commit is contained in:
Vladimir Mihailenco
2013-09-28 13:24:22 +03:00
parent 9462848b74
commit 8d6a169007
3 changed files with 148 additions and 169 deletions

View File

@ -115,20 +115,19 @@ func ExamplePubSub() {
pubsub, err := client.PubSubClient()
defer pubsub.Close()
ch, err := pubsub.Subscribe("mychannel")
_ = err
err = pubsub.Subscribe("mychannel")
subscribeMsg := <-ch
fmt.Println(subscribeMsg.Err, subscribeMsg.Name)
msg, err := pubsub.Receive(0)
fmt.Println(msg, err)
pub := client.Publish("mychannel", "hello")
_ = pub.Err()
msg := <-ch
fmt.Println(msg.Err, msg.Message)
msg, err = pubsub.Receive(0)
fmt.Println(msg, err)
// Output: <nil> subscribe
// <nil> hello
// Output: &{subscribe mychannel 1} <nil>
// &{mychannel hello} <nil>
}
func Get(client *redis.Client, key string) *redis.StringReq {