redis.go 452 Bytes
Newer Older
haoyanbin's avatar
haoyanbin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
package redis

import (
	"fmt"
	"github.com/go-redis/redis"
)

const (
	host     = "39.96.85.45"
	port     = 6382
	password = "saas123456"
	db       = 6
)

// 初始化连接
func Init() (client *redis.Client) {
	client = redis.NewClient(&redis.Options{
		Addr:     fmt.Sprintf("%s:%d", host, port),
		Password: password,
		DB:       db, // use default DB
	})
	_, err := client.Ping().Result()
	if err != nil {
haoyanbin's avatar
haoyanbin committed
24
		fmt.Println("redis:",err)
haoyanbin's avatar
haoyanbin committed
25 26 27
	}
	return
}