1.代码实现
package main import ( "fmt" "github.com/gomodule/redigo/redis" ) var pool *redis.Pool; func init(){ pool = &redis.Pool{ MaxIdle: 8, MaxActive:0, IdleTimeout: 100, Dial: func() (redis.Conn, error) { return redis.Dial("tcp","localhost:6379") }, } } func main(){ conn := pool.Get(); conn.Do("set","name","lisoi"); s, err := redis.String(conn.Do("get","name")); if err !=nil { fmt.Println("is error"); } fmt.Println(s); }