1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

Replace PoolStats.Requests with PoolStats.Misses

This commit is contained in:
Vladimir Mihailenco
2017-09-22 12:23:46 +03:00
parent fdafb11e5f
commit bc5f9a6878
6 changed files with 49 additions and 35 deletions

View File

@ -23,8 +23,8 @@ var timers = sync.Pool{
// Stats contains pool state information and accumulated stats.
type Stats struct {
Requests uint32 // number of times a connection was requested by the pool
Hits uint32 // number of times free connection was found in the pool
Misses uint32 // number of times free connection was NOT found in the pool
Timeouts uint32 // number of times a wait timeout occurred
TotalConns uint32 // number of total connections in the pool
@ -151,8 +151,6 @@ func (p *ConnPool) Get() (*Conn, bool, error) {
return nil, false, ErrClosed
}
atomic.AddUint32(&p.stats.Requests, 1)
select {
case p.queue <- struct{}{}:
default:
@ -190,6 +188,8 @@ func (p *ConnPool) Get() (*Conn, bool, error) {
return cn, false, nil
}
atomic.AddUint32(&p.stats.Misses, 1)
newcn, err := p.NewConn()
if err != nil {
<-p.queue
@ -266,8 +266,8 @@ func (p *ConnPool) FreeLen() int {
func (p *ConnPool) Stats() *Stats {
return &Stats{
Requests: atomic.LoadUint32(&p.stats.Requests),
Hits: atomic.LoadUint32(&p.stats.Hits),
Misses: atomic.LoadUint32(&p.stats.Misses),
Timeouts: atomic.LoadUint32(&p.stats.Timeouts),
TotalConns: uint32(p.Len()),