redis client原理分析

代码库地址: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 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值