Skip to content

Instantly share code, notes, and snippets.

@pm-kartik-sura
Created May 19, 2015 09:19
Show Gist options
  • Select an option

  • Save pm-kartik-sura/9603515e2fdd4d788b44 to your computer and use it in GitHub Desktop.

Select an option

Save pm-kartik-sura/9603515e2fdd4d788b44 to your computer and use it in GitHub Desktop.
Redigo pools
package main
import "fmt"
import "github.com/garyburd/redigo/redis"
func newPool() *redis.Pool {
return &redis.Pool{
MaxIdle: 80,
MaxActive: 12000, // max number of connections
Dial: func() (redis.Conn, error) {
c, err := redis.Dial("tcp", ":6379")
if err != nil {
panic(err.Error())
}
return c, err
},
}
}
var pool = newPool()
func main() {
c := pool.Get()
defer c.Close()
test,_:=c.Do("HGETALL", "test:1")
fmt.Println(test)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment