mirror of
https://github.com/gofiber/storage.git
synced 2025-10-05 08:37:10 +08:00
refactor: use TRUNCATE to reset the tables for postgres/ mysql (#74)
MySQL docs: https://dev.mysql.com/doc/refman/8.0/en/truncate-table.html Postgres docs: https://www.postgresql.org/docs/current/sql-truncate.html
This commit is contained in:
@@ -81,7 +81,7 @@ func New(config ...Config) *Storage {
|
|||||||
sqlSelect: fmt.Sprintf("SELECT v, e FROM %s WHERE k=?;", cfg.Table),
|
sqlSelect: fmt.Sprintf("SELECT v, e FROM %s WHERE k=?;", cfg.Table),
|
||||||
sqlInsert: fmt.Sprintf("INSERT INTO %s (k, v, e) VALUES (?,?,?) ON DUPLICATE KEY UPDATE v = ?, e = ?", cfg.Table),
|
sqlInsert: fmt.Sprintf("INSERT INTO %s (k, v, e) VALUES (?,?,?) ON DUPLICATE KEY UPDATE v = ?, e = ?", cfg.Table),
|
||||||
sqlDelete: fmt.Sprintf("DELETE FROM %s WHERE k=?", cfg.Table),
|
sqlDelete: fmt.Sprintf("DELETE FROM %s WHERE k=?", cfg.Table),
|
||||||
sqlReset: fmt.Sprintf("DELETE FROM %s;", cfg.Table),
|
sqlReset: fmt.Sprintf("TRUNCATE TABLE %s;", cfg.Table),
|
||||||
sqlGC: fmt.Sprintf("DELETE FROM %s WHERE e <= ? AND e != 0", cfg.Table),
|
sqlGC: fmt.Sprintf("DELETE FROM %s WHERE e <= ? AND e != 0", cfg.Table),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -99,7 +99,7 @@ func New(config ...Config) *Storage {
|
|||||||
sqlSelect: fmt.Sprintf(`SELECT v, e FROM %s WHERE k=$1;`, cfg.Table),
|
sqlSelect: fmt.Sprintf(`SELECT v, e FROM %s WHERE k=$1;`, cfg.Table),
|
||||||
sqlInsert: fmt.Sprintf("INSERT INTO %s (k, v, e) VALUES ($1, $2, $3) ON CONFLICT (k) DO UPDATE SET v = $4, e = $5", cfg.Table),
|
sqlInsert: fmt.Sprintf("INSERT INTO %s (k, v, e) VALUES ($1, $2, $3) ON CONFLICT (k) DO UPDATE SET v = $4, e = $5", cfg.Table),
|
||||||
sqlDelete: fmt.Sprintf("DELETE FROM %s WHERE k=$1", cfg.Table),
|
sqlDelete: fmt.Sprintf("DELETE FROM %s WHERE k=$1", cfg.Table),
|
||||||
sqlReset: fmt.Sprintf("DELETE FROM %s;", cfg.Table),
|
sqlReset: fmt.Sprintf("TRUNCATE TABLE %s;", cfg.Table),
|
||||||
sqlGC: fmt.Sprintf("DELETE FROM %s WHERE e <= $1 AND e != 0", cfg.Table),
|
sqlGC: fmt.Sprintf("DELETE FROM %s WHERE e <= $1 AND e != 0", cfg.Table),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user