c := redisPool.Get()
    psc := redis.PubSubConn{c}
    psc.PSubscribe("aa*")
    for {
        switch v := psc.Receive().(type) {
        case redis.Subscription:
            fmt.Printf("%s: %s %d\n", v.Channel, v.Kind, v.Count)
        case redis.Message://单个订阅subscribe
            fmt.Printf("%s: message: %s\n", v.Channel, v.Data)
        case redis.PMessage://模式订阅psubscribe
            fmt.Printf("PMessage: %s %s %s\n", v.Pattern, v.Channel, v.Data)
        case error:
            return

        }

    }

 

相关文章:

  • 2022-01-10
  • 2022-12-23
  • 2022-12-23
  • 2021-07-27
  • 2021-06-08
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-25
  • 2022-12-23
  • 2021-06-01
  • 2021-12-20
  • 2022-03-04
相关资源
相似解决方案