Skip to content

Commit

Permalink
Merge branch 'master' of github.com:wladh/redis.go into wladh-master
Browse files Browse the repository at this point in the history
  • Loading branch information
hoisie committed Jun 26, 2013
2 parents 8b62c90 + 91e4e66 commit c044ea7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ import (
)

const (
MaxPoolSize = 5
defaultPoolSize = 5
)

var defaultAddr = "127.0.0.1:6379"

type Client struct {
Addr string
Db int
Password string
Addr string
Db int
Password string
MaxPoolSize int
//the connection pool
pool chan net.Conn
}
Expand Down Expand Up @@ -289,8 +290,12 @@ End:

func (client *Client) popCon() (net.Conn, error) {
if client.pool == nil {
client.pool = make(chan net.Conn, MaxPoolSize)
for i := 0; i < MaxPoolSize; i++ {
poolSize := client.MaxPoolSize
if poolSize == 0 {
poolSize = defaultPoolSize
}
client.pool = make(chan net.Conn, poolSize)
for i := 0; i < poolSize; i++ {
//add dummy values to the pool
client.pool <- nil
}
Expand Down

0 comments on commit c044ea7

Please sign in to comment.