gf/geg/database/gredis/gredis_conn_subscribe_var.go

23 lines
306 B
Go
Raw Normal View History

2019-03-21 23:51:57 +08:00
package main
import (
2019-06-12 21:06:57 +08:00
"fmt"
"github.com/gogf/gf/g"
2019-03-21 23:51:57 +08:00
)
func main() {
2019-04-03 00:03:46 +08:00
conn := g.Redis().Conn()
defer conn.Close()
_, err := conn.Do("SUBSCRIBE", "channel")
if err != nil {
panic(err)
}
for {
reply, err := conn.ReceiveVar()
2019-04-03 00:03:46 +08:00
if err != nil {
panic(err)
}
fmt.Println(reply.Strings())
2019-04-03 00:03:46 +08:00
}
2019-03-21 23:51:57 +08:00
}