代码库地址:https://github.com/garyburd/redigo
- 1:连接池
- 2:发送命令
- 3:解析结果
1:连接池
连接池结构体如下:
type Pool struct { // Dial is an application supplied function for creating and configuring a // connection. // // The connection returned from Dial must not be in a special state // (subscribed to pubsub channel, transaction started, ...). Dial func() (Conn, error) //生成网络连接对象 // TestOnBorrow is an optional application supplied function for checking // the health of an idle connection before the connection is used again by // the application. Argument t is the time that the connection was returned // to the pool. If the function returns an error, then the connection is // closed. TestOnBorrow func(c Conn, t time.Time) error //测试连接是否通畅 // Maximum number of idle connections in the pool. MaxIdle int //最大空闲连接数 // Maximum number of connections allocated by the pool at a given time. // When zero, there is no limit on the number of connections in the pool. MaxActive int //最大活动(正在执行任务)连接数 // Close connections after remaining idle for this duration. If the value // is zero, then idle connections are not