Browse Source

redisc update

marion 4 years ago
parent
commit
c6c68ea0ba
1 changed files with 2 additions and 3 deletions
  1. 2 3
      utils/redis/redis_conn.go

+ 2 - 3
utils/redis/redis_conn.go

@@ -74,10 +74,9 @@ func (h *Hub) conn() error {
 	} else { // 单点
 		var pool *redis.Pool
 		host := viper.GetString("redis.host")
-		opts := []redis.DialOption{redis.DialConnectTimeout(5 * time.Second)}
 		password := viper.GetString("redis.password")
 		if len(strings.TrimSpace(password)) > 0 {
-			opts = append(opts, redis.DialPassword(strings.TrimSpace(password)))
+			dialOpts = append(dialOpts, redis.DialPassword(strings.TrimSpace(password)))
 		}
 		pool, _ = h.createPool(host, dialOpts...)
 		h.pool = pool
@@ -150,7 +149,7 @@ func (h *Hub) Do(cmd string, args ...interface{}) (interface{}, error) {
 		_ = conn.Close()
 	}(conn)
 
-	if nil != conn {
+	if nil == conn {
 		return nil, ErrRedisConnNil
 	} else {
 		reply, err := conn.Do(cmd, args...)