Subscribe subscribes the client to the specified channels. Channels can be omitted to create empty subscription. Note that this method does not wait on a response from Redis, so the subscription may not be active immediately. To force the connection to wait, you may call the Receive() method on the
(ctx context.Context, channels ...string)
| 1595 | // |
| 1596 | // ch := sub.Channel() |
| 1597 | func (c *Client) Subscribe(ctx context.Context, channels ...string) *PubSub { |
| 1598 | pubsub := c.pubSub() |
| 1599 | if len(channels) > 0 { |
| 1600 | _ = pubsub.Subscribe(ctx, channels...) |
| 1601 | } |
| 1602 | return pubsub |
| 1603 | } |
| 1604 | |
| 1605 | // PSubscribe subscribes the client to the given patterns. |
| 1606 | // Patterns can be omitted to create empty subscription. |