Created
May 19, 2015 09:19
-
-
Save pm-kartik-sura/9603515e2fdd4d788b44 to your computer and use it in GitHub Desktop.
Redigo pools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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