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

Simplify PubSub API

This commit is contained in:
Vladimir Mihailenco
2017-04-11 16:53:55 +03:00
parent 3b1a641e2c
commit 8d52a95269
7 changed files with 41 additions and 78 deletions

View File

@ -258,13 +258,10 @@ func ExampleClient_Watch() {
}
func ExamplePubSub() {
pubsub, err := client.Subscribe("mychannel1")
if err != nil {
panic(err)
}
pubsub := client.Subscribe("mychannel1")
defer pubsub.Close()
err = client.Publish("mychannel1", "hello").Err()
err := client.Publish("mychannel1", "hello").Err()
if err != nil {
panic(err)
}
@ -279,10 +276,7 @@ func ExamplePubSub() {
}
func ExamplePubSub_Receive() {
pubsub, err := client.Subscribe("mychannel2")
if err != nil {
panic(err)
}
pubsub := client.Subscribe("mychannel2")
defer pubsub.Close()
n, err := client.Publish("mychannel2", "hello").Result()