|
@@ -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...)
|