mirror of
https://github.com/gofiber/storage.git
synced 2025-10-26 09:50:30 +08:00
Fix rueidis startup check handling and revert mysql changes
This commit is contained in:
@@ -127,11 +127,6 @@ type Config struct {
|
||||
// Optional. Default is false
|
||||
Reset bool
|
||||
|
||||
// DisableStartupCheck skips the initial connection validation during New.
|
||||
//
|
||||
// Optional. Default is false
|
||||
DisableStartupCheck bool
|
||||
|
||||
// Time before deleting expired keys
|
||||
//
|
||||
// Optional. Default is 10 * time.Second
|
||||
@@ -148,7 +143,6 @@ var ConfigDefault = Config{
|
||||
Database: "fiber",
|
||||
Table: "fiber_storage",
|
||||
Reset: false,
|
||||
DisableStartupCheck: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
}
|
||||
```
|
||||
|
||||
@@ -53,11 +53,6 @@ type Config struct {
|
||||
// Optional. Default is false
|
||||
Reset bool
|
||||
|
||||
// DisableStartupCheck skips the initial connection validation during New.
|
||||
//
|
||||
// Optional. Default is false
|
||||
DisableStartupCheck bool
|
||||
|
||||
// Time before deleting expired keys
|
||||
//
|
||||
// Optional. Default is 10 * time.Second
|
||||
@@ -81,7 +76,6 @@ var ConfigDefault = Config{
|
||||
Database: "fiber",
|
||||
Table: "fiber_storage",
|
||||
Reset: false,
|
||||
DisableStartupCheck: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
maxOpenConns: 100,
|
||||
maxIdleConns: 100,
|
||||
|
||||
@@ -63,7 +63,6 @@ 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 {
|
||||
panic(err)
|
||||
@@ -86,7 +85,6 @@ func New(config ...Config) *Storage {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create storage
|
||||
store := &Storage{
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
// Start garbage collector
|
||||
go store.gcTicker()
|
||||
|
||||
@@ -108,18 +108,6 @@ func Test_MYSQL_New(t *testing.T) {
|
||||
defer newConfigStore.Close()
|
||||
}
|
||||
|
||||
func Test_MYSQL_New_DisableStartupCheck(t *testing.T) {
|
||||
require.NotPanics(t, func() {
|
||||
store := New(Config{
|
||||
Host: "127.0.0.1",
|
||||
Port: 3308,
|
||||
DisableStartupCheck: true,
|
||||
})
|
||||
require.NotNil(t, store)
|
||||
defer store.Close()
|
||||
})
|
||||
}
|
||||
|
||||
func Test_MYSQL_GC(t *testing.T) {
|
||||
testVal := []byte("doe")
|
||||
|
||||
|
||||
@@ -63,10 +63,10 @@ func New(config ...Config) *Storage {
|
||||
AlwaysPipelining: cfg.AlwaysPipelining,
|
||||
})
|
||||
if err != nil {
|
||||
if !cfg.DisableStartupCheck {
|
||||
panic(err)
|
||||
}
|
||||
} else if !cfg.DisableStartupCheck {
|
||||
|
||||
if !cfg.DisableStartupCheck {
|
||||
// Test connection
|
||||
if err := db.Do(context.Background(), db.B().Ping().Build()).Error(); err != nil {
|
||||
panic(err)
|
||||
|
||||
Reference in New Issue
Block a user