Skip to content

Commit

Permalink
faet: stats
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroyky committed Nov 17, 2023
1 parent 37ae0da commit ae929eb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions memcache/memcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,3 +718,18 @@ func (c *Client) Close() error {
c.pools = make(map[string]*pool)
return ret
}

func (c *Client) Stats() []*Stats {
stats := make([]*Stats, 0)
for ad, p := range c.pools {
stat := &Stats{
Address: ad,
MaxIdleConnections: c.maxIdleConns(),
MaxOpenConnections: c.MaxOpenConns,
OpenConnsNum: p.openconnsNum,
IdleConnsNum: p.freeconnsNum,
}
stats = append(stats, stat)
}
return stats
}
9 changes: 9 additions & 0 deletions memcache/stats.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package memcache

type Stats struct {
Address string
MaxIdleConnections int
MaxOpenConnections int
OpenConnsNum int
IdleConnsNum int
}

0 comments on commit ae929eb

Please sign in to comment.