package main
import (
"github.com/garyburd/redigo/redis"
"fmt"
)
var pool = newPool()
func newPool() *redis.Pool {
return &redis.Pool{
MaxIdle: 80,
MaxActive: 12000, // max number of connections
Dial: func() (redis.Conn, error) {
c, err := redis.Dial("tcp", "localhost:6379")
if err != nil {
panic(err.Error())
}
return c, err
},
}
}
func main() {
c := pool.Get()
defer c.Close()
que, err := redis.String(c.Do("LPOP", "test"))
fmt.Println(que)
if err != nil {
fmt.Println("队列空")
}
}
http://stackoverflow.com/questions/24387350/re-using-redigo-connection-instead-of-recreating-it-every-time
http://blog.csdn.net/stevefang/article/details/40474827
标签:none