1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| package cache
|
| import (
| "fmt"
| "github.com/astaxie/beego"
| redigo "github.com/gomodule/redigo/redis"
| )
|
| var pool *redigo.Pool
|
| func init() {
| redisHost := beego.AppConfig.String("redisIp")
| redisPort,_ := beego.AppConfig.Int("redisPort")
| poolSize := 20
| pool = redigo.NewPool(func() (redigo.Conn, error) {
| c, err := redigo.Dial("tcp", fmt.Sprintf("%s:%d", redisHost, redisPort))
| if err != nil {
| return nil, err
| }
| return c, nil
| }, poolSize)
| }
|
| func Get() redigo.Conn {
| return pool.Get()
| }
|
|