mirror of
https://github.com/gofiber/storage.git
synced 2025-10-04 16:22:52 +08:00
remove close method
This commit is contained in:
@@ -98,11 +98,6 @@ func (s *Storage) Clear() error {
|
||||
return s.db.DeleteAll()
|
||||
}
|
||||
|
||||
// Close the storage
|
||||
func (s *Storage) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Acquire item from pool
|
||||
func (s *Storage) acquireItem() *mc.Item {
|
||||
return s.items.Get().(*mc.Item)
|
||||
|
@@ -83,11 +83,6 @@ func (s *Storage) Clear() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Close the storage
|
||||
func (s *Storage) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Storage) gc() {
|
||||
for t := range time.NewTicker(s.gcInterval).C {
|
||||
now := t.Unix()
|
||||
|
@@ -157,11 +157,6 @@ func (s *Storage) Clear() error {
|
||||
return s.col.Drop(context.Background())
|
||||
}
|
||||
|
||||
// Close database connection
|
||||
func (s *Storage) Close() error {
|
||||
return s.db.Client().Disconnect(context.Background())
|
||||
}
|
||||
|
||||
// Acquire item from pool
|
||||
func (s *Storage) acquireItem() *item {
|
||||
return s.items.Get().(*item)
|
||||
|
@@ -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 INTO %s (id, data, exp) VALUES (?,?,?)", cfg.Table),
|
||||
sqlInsert: fmt.Sprintf("INSERT INTO %s (id, data, exp) VALUES (?,?,?) ON DUPLICATE KEY UPDATE data = ?, exp = ?", 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),
|
||||
@@ -126,7 +126,8 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
||||
if exp != 0 {
|
||||
expSeconds = time.Now().Add(exp).Unix()
|
||||
}
|
||||
_, err := s.db.Exec(s.sqlInsert, key, utils.UnsafeString(val), expSeconds)
|
||||
valStr := utils.UnsafeString(val)
|
||||
_, err := s.db.Exec(s.sqlInsert, key, valStr, expSeconds, valStr, expSeconds)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -142,11 +143,6 @@ 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)
|
||||
|
@@ -158,11 +158,6 @@ func (s *Storage) Clear() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Close the storage
|
||||
func (s *Storage) Close() error {
|
||||
return s.db.Close()
|
||||
}
|
||||
|
||||
// GC deletes all expired entries
|
||||
func (s *Storage) gc() {
|
||||
tick := time.NewTicker(s.gcInterval)
|
||||
|
@@ -75,8 +75,3 @@ func (s *Storage) Delete(key string) error {
|
||||
func (s *Storage) Clear() error {
|
||||
return s.db.FlushDB(context.Background()).Err()
|
||||
}
|
||||
|
||||
// Close the storage
|
||||
func (s *Storage) Close() error {
|
||||
return s.db.Close()
|
||||
}
|
||||
|
@@ -141,11 +141,6 @@ func (s *Storage) Clear() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Close the storage
|
||||
func (s *Storage) Close() error {
|
||||
return s.db.Close()
|
||||
}
|
||||
|
||||
// GC deletes all expired entries
|
||||
func (s *Storage) gc() {
|
||||
tick := time.NewTicker(s.gcInterval)
|
||||
|
Reference in New Issue
Block a user