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:
Roman
2021-03-31 14:11:33 +02:00
committed by GitHub
parent f69705a65d
commit 8a84698537
2 changed files with 2 additions and 2 deletions

View File

@@ -81,7 +81,7 @@ func New(config ...Config) *Storage {
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),
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),
}