dongsaolian8786
dongsaolian8786
2016-12-10 16:53
浏览 445

go-redis中PoolTimeout,IdleTimeout和IdleCheckFrequency之间的关系

Can someone let me know the relation between PoolTimeout, IdleTimeout & IdleCheckFrequency in go-redis?

Doubts:-

  1. If I specify PoolTimeout 20ms, IdleTimeout 20ms, PoolSize 100 & IdleCheckFrequency 1 min. Let's say all the connection in the pool are used and a connection finishes its operation. Then will the request for a new connection wait till the IdleCheck is run in 1 min interval?
  2. If I specify PoolSize 100 will the client keep open 100 connections to redis even if there is no active client operation being performed to Redis?

Environment:-

  1. Go - 1.7.4
  2. Redis - 3.2.6
  3. Go-Redis - v5.2
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douduan6731
    douduan6731 2016-12-12 06:54
    已采纳

    This has been answered in github here. Just posting the relevant parts below:-

    PoolSize limits max number of open connections. If app is idle then go-redis does not open any connections.

    New connection is opened when there is a command to process and there are no idle connections in the pool. Idle connections are closed after they are idle for IdleTimeout.

    IdleCheckFrequency specifies how often we check if connection is expired. This is needed in case app is idle and there is no activity. Normally idle connections are closed when go-redis asks pool for a (healthy) connection.

    点赞 评论

相关推荐