mirror of
https://github.com/gofiber/storage.git
synced 2025-10-26 18:00:26 +08:00
Fix rueidis startup check handling and revert mysql changes
This commit is contained in:
@@ -63,28 +63,26 @@ func New(config ...Config) *Storage {
|
||||
db.SetConnMaxLifetime(cfg.connMaxLifetime)
|
||||
}
|
||||
|
||||
if !cfg.DisableStartupCheck {
|
||||
// Ping database to ensure a connection has been made
|
||||
if err := db.Ping(); err != nil {
|
||||
// Ping database to ensure a connection has been made
|
||||
if err := db.Ping(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Drop table if Clear set to true
|
||||
if cfg.Reset {
|
||||
query := fmt.Sprintf(dropQuery, cfg.Table)
|
||||
if _, err = db.Exec(query); err != nil {
|
||||
_ = db.Close()
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Drop table if Clear set to true
|
||||
if cfg.Reset {
|
||||
query := fmt.Sprintf(dropQuery, cfg.Table)
|
||||
if _, err = db.Exec(query); err != nil {
|
||||
_ = db.Close()
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Init database queries
|
||||
for _, query := range initQuery {
|
||||
query = fmt.Sprintf(query, cfg.Table)
|
||||
if _, err := db.Exec(query); err != nil {
|
||||
_ = db.Close()
|
||||
panic(err)
|
||||
}
|
||||
// Init database queries
|
||||
for _, query := range initQuery {
|
||||
query = fmt.Sprintf(query, cfg.Table)
|
||||
if _, err := db.Exec(query); err != nil {
|
||||
_ = db.Close()
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,9 +98,7 @@ func New(config ...Config) *Storage {
|
||||
sqlGC: fmt.Sprintf("DELETE FROM %s WHERE e <= ? AND e != 0", cfg.Table),
|
||||
}
|
||||
|
||||
if !cfg.DisableStartupCheck {
|
||||
store.checkSchema(cfg.Table)
|
||||
}
|
||||
store.checkSchema(cfg.Table)
|
||||
|
||||
// Start garbage collector
|
||||
go store.gcTicker()
|
||||
|
||||
Reference in New Issue
Block a user