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\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

        }

    }

 

posted @ 2015-11-30 18:32  程序员老刘  阅读(3927)  评论(0编辑  收藏  举报