package services import ( "github.com/go-redis/redis" ) type RedisService struct { //client *redis.Client } var RedisConn *redis.ClusterClient //var RedisConn *redis.Client func init() { RedisConn = redis.NewClusterClient(&redis.ClusterOptions{ Addrs: []string{"192.168.1.24:6379", "192.168.1.24:6380", "192.168.1.25:6379", "192.168.1.25:6380", "192.168.1.26:6379", "192.168.1.26:6380"}, //set redis cluster url Password: "", PoolSize: 100, MinIdleConns: 50, }) //RedisConn = redis.NewClient(&redis.Options{ // Addr: beego.AppConfig.String("redis.addr"), // Password: beego.AppConfig.String("redis.passwd"), // no password set // DB: 0, // use default DB // DialTimeout: 2000 * time.Millisecond, // ReadTimeout: 2000 * time.Millisecond, // PoolSize: 100, // IdleCheckFrequency: 300 * time.Second, // MinIdleConns: 100, //}) }