mirror of
https://github.com/gofiber/storage.git
synced 2025-10-05 08:37:10 +08:00
sql queries T.T
This commit is contained in:
@@ -76,7 +76,7 @@ func New(config ...Config) *Storage {
|
||||
gcInterval: cfg.GCInterval,
|
||||
db: db,
|
||||
sqlSelect: fmt.Sprintf("SELECT data, exp FROM %s WHERE id=?;", cfg.Table),
|
||||
sqlInsert: fmt.Sprintf("INSERT OR REPLACE INTO %s (id, data, exp) VALUES (?,?,?)", cfg.Table),
|
||||
sqlInsert: fmt.Sprintf("INSERT INTO %s (id, data, exp) VALUES (?,?,?)", cfg.Table),
|
||||
sqlDelete: fmt.Sprintf("DELETE FROM %s WHERE id=?", cfg.Table),
|
||||
sqlClear: fmt.Sprintf("DELETE FROM %s;", cfg.Table),
|
||||
sqlGC: fmt.Sprintf("DELETE FROM %s WHERE exp <= ?", cfg.Table),
|
||||
@@ -142,6 +142,11 @@ func (s *Storage) Clear() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Close the storage
|
||||
func (s *Storage) Close() error {
|
||||
return s.db.Close()
|
||||
}
|
||||
|
||||
// Garbage collector to delete expired keys
|
||||
func (s *Storage) gc() {
|
||||
tick := time.NewTicker(s.gcInterval)
|
||||
|
Reference in New Issue
Block a user