🧹 introduce reset and close

This commit is contained in:
Fenny
2020-11-06 01:41:46 +01:00
parent 1634e44e61
commit f9a30234b9
28 changed files with 125 additions and 87 deletions

View File

@@ -152,11 +152,16 @@ func (s *Storage) Delete(key string) error {
return err
}
// Clear all keys by drop collection
func (s *Storage) Clear() error {
// Reset all keys by drop collection
func (s *Storage) Reset() error {
return s.col.Drop(context.Background())
}
// Close the database
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)