Skip to content

Commit

Permalink
Add an example of Redis conn pool closing
Browse files Browse the repository at this point in the history
  • Loading branch information
marselester committed Mar 18, 2023
1 parent bed471f commit 0882ef3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/redis/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ func main() {
// Close connections after remaining idle for given duration.
IdleTimeout: 5 * time.Minute,
}
defer func() {
if err := pool.Close(); err != nil {
level.Error(logger).Log("msg", "failed to close Redis connection pool", "err", err)
}
}()

c := pool.Get()
if _, err := c.Do("PING"); err != nil {
level.Error(logger).Log("msg", "Redis connection failed", "err", err)
Expand Down

0 comments on commit 0882ef3

Please sign in to comment.