Skip to content

Commit 0882ef3

Browse files
committed
Add an example of Redis conn pool closing
1 parent bed471f commit 0882ef3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

examples/redis/main.go

+6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ func main() {
5252
// Close connections after remaining idle for given duration.
5353
IdleTimeout: 5 * time.Minute,
5454
}
55+
defer func() {
56+
if err := pool.Close(); err != nil {
57+
level.Error(logger).Log("msg", "failed to close Redis connection pool", "err", err)
58+
}
59+
}()
60+
5561
c := pool.Get()
5662
if _, err := c.Do("PING"); err != nil {
5763
level.Error(logger).Log("msg", "Redis connection failed", "err", err)

0 commit comments

Comments
 (0)