Pārlūkot izejas kodu

Improve pool documentation

- Show how to use time in TestOnBorrow.
- Note that the example is an example, not a recommendation.
Gary Burd 9 gadi atpakaļ
vecāks
revīzija
a6abb2845e
1 mainītis faili ar 5 papildinājumiem un 1 dzēšanām
  1. 5 1
      redis/pool.go

+ 5 - 1
redis/pool.go

@@ -46,7 +46,8 @@ var (
 //
 // The following example shows how to use a pool in a web application. The
 // application creates a pool at application startup and makes it available to
-// request handlers using a global variable.
+// request handlers using a global variable. The pool configuration used here
+// is an example, not a recommendation. 
 //
 //  func newPool(server, password string) *redis.Pool {
 //      return &redis.Pool{
@@ -64,6 +65,9 @@ var (
 //              return c, err
 //          },
 //          TestOnBorrow: func(c redis.Conn, t time.Time) error {
+//              if time.Since(t) < time.Minute {
+//                  return nil
+//              }
 //              _, err := c.Do("PING")
 //              return err
 //          },