mirror of
https://github.com/gofiber/storage.git
synced 2025-10-06 00:57:38 +08:00
Fix syntax issues
This commit is contained in:
@@ -19,11 +19,8 @@ func New(config ...Config) *Storage {
|
|||||||
cfg := configDefault(config...)
|
cfg := configDefault(config...)
|
||||||
|
|
||||||
// Create new redis client
|
// Create new redis client
|
||||||
var options *redis.Options
|
|
||||||
var err error
|
|
||||||
|
|
||||||
if cfg.URL != "" && !cfg.EnableFailover {
|
if cfg.URL != "" && !cfg.EnableFailover {
|
||||||
options, err = redis.ParseURL(cfg.URL)
|
options, err := redis.ParseURL(cfg.URL)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -31,9 +28,9 @@ func New(config ...Config) *Storage {
|
|||||||
|
|
||||||
options.TLSConfig = cfg.TLSConfig
|
options.TLSConfig = cfg.TLSConfig
|
||||||
options.PoolSize = cfg.PoolSize
|
options.PoolSize = cfg.PoolSize
|
||||||
db = redis.NewClient(options)
|
db := redis.NewClient(options)
|
||||||
} else if cfg.EnableFailover {
|
} else if cfg.EnableFailover {
|
||||||
options = &redis.FailoverOptions{
|
options := &redis.FailoverOptions{
|
||||||
MasterName: cfg.MasterName,
|
MasterName: cfg.MasterName,
|
||||||
SentinelAddrs: cfg.SentinelHosts,
|
SentinelAddrs: cfg.SentinelHosts,
|
||||||
ClientName: cfg.ClientName,
|
ClientName: cfg.ClientName,
|
||||||
@@ -44,9 +41,9 @@ func New(config ...Config) *Storage {
|
|||||||
TLSConfig: cfg.TLSConfig,
|
TLSConfig: cfg.TLSConfig,
|
||||||
PoolSize: cfg.PoolSize,
|
PoolSize: cfg.PoolSize,
|
||||||
}
|
}
|
||||||
db = redis.NewFailoverClient(options)
|
db := redis.NewFailoverClient(options)
|
||||||
} else {
|
} else {
|
||||||
options = &redis.Options{
|
options := &redis.Options{
|
||||||
Addr: fmt.Sprintf("%s:%d", cfg.Host, cfg.Port),
|
Addr: fmt.Sprintf("%s:%d", cfg.Host, cfg.Port),
|
||||||
DB: cfg.Database,
|
DB: cfg.Database,
|
||||||
Username: cfg.Username,
|
Username: cfg.Username,
|
||||||
|
Reference in New Issue
Block a user