Skip to content

Instantly share code, notes, and snippets.

@g-dormoy
Created October 24, 2014 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save g-dormoy/af171b5171f17c7fdb81 to your computer and use it in GitHub Desktop.
Save g-dormoy/af171b5171f17c7fdb81 to your computer and use it in GitHub Desktop.
return a pool of 50 redis connection
package main
import "github.com/garyburd/redigo/redis"
func GetRedisConnection() (*redis.Pool, error) {
connPool := redis.NewPool(func() (redis.Conn, error) {
conn, err := redis.Dial("tcp", "redis.host:6379")
if err != nil {
return nil, err
}
return conn, err
}, 50)
return connPool, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment