|
@@ -2,6 +2,7 @@ package ads_redis
|
2
|
2
|
|
3
|
3
|
import (
|
4
|
4
|
"fmt"
|
|
5
|
+ "miads/adslib"
|
5
|
6
|
"time"
|
6
|
7
|
|
7
|
8
|
"github.com/gomodule/redigo/redis"
|
|
@@ -9,22 +10,21 @@ import (
|
9
|
10
|
|
10
|
11
|
var RedisConn *redis.Pool
|
11
|
12
|
|
12
|
|
-var HOST = ""
|
13
|
|
-var PASSWORD = ""
|
14
|
|
-
|
15
|
13
|
func Setup() error {
|
|
14
|
+ host := adslib.GetConf().RedisHost
|
|
15
|
+ password := adslib.GetConf().RedisPassword
|
16
|
16
|
RedisConn = &redis.Pool{
|
17
|
17
|
MaxIdle: 10,
|
18
|
18
|
MaxActive: 10,
|
19
|
19
|
IdleTimeout: 50,
|
20
|
20
|
Dial: func() (redis.Conn, error) {
|
21
|
|
- c, err := redis.Dial("tcp", HOST)
|
|
21
|
+ c, err := redis.Dial("tcp", host)
|
22
|
22
|
if err != nil {
|
23
|
23
|
fmt.Println(err)
|
24
|
24
|
return nil, err
|
25
|
25
|
}
|
26
|
|
- if PASSWORD != "" {
|
27
|
|
- if _, err := c.Do("AUTH", PASSWORD); err != nil {
|
|
26
|
+ if password != "" {
|
|
27
|
+ if _, err := c.Do("AUTH", password); err != nil {
|
28
|
28
|
fmt.Println(err)
|
29
|
29
|
c.Close()
|
30
|
30
|
return nil, err
|
|
@@ -41,4 +41,3 @@ func Setup() error {
|
41
|
41
|
|
42
|
42
|
return nil
|
43
|
43
|
}
|
44
|
|
-
|