golang redis的模式订阅

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

        }

    }
原文地址:https://www.cnblogs.com/liughost/p/5008029.html