redisgo可以使用连接池:
pool = &redis.Pool{ Dial: func() (conn redis.Conn, e error) { return redis.Dial("tcp","192.168.50.131:6379") }, MaxIdle:3, MaxActive:5, IdleTimeout:240 * time.Second, }
连接池的使用:
conn := pool.Get() defer conn.Close() conn.Do("set","addr","wuhan")
请发表评论