func NewRedisStore(hostPort string, database int) *RedisStore { client := redis.NewTCPClient(&redis.Options{ Addr: hostPort, Password: "", // no password set DB: int64(database), }) return &RedisStore{Client: client} }
func initRedis() { redisDB = redis.NewTCPClient(&redis.Options{ Addr: fmt.Sprintf("%s:%d", "localhost", 6379), DB: int64(1), // use default DB }) fmt.Println(redisDB) }
func (self Connection) Connect() (r *redis.Client, err error) { r = redis.NewTCPClient(&redis.Options{ Addr: self.Host, Password: self.Password, DB: self.Db, }) ping := r.Ping() if err = ping.Err(); err != nil { return } return }