added store.RemoveAll() helper method

This commit is contained in:
Gani Georgiev
2022-07-14 16:39:42 +03:00
parent 6749559a22
commit d129959098
2 changed files with 22 additions and 0 deletions
+8
View File
@@ -13,6 +13,14 @@ func New[T any](data map[string]T) *Store[T] {
return &Store[T]{data: data}
}
// RemoveAll removes all the existing store entries.
func (s *Store[T]) RemoveAll() {
s.mux.Lock()
defer s.mux.Unlock()
s.data = make(map[string]T)
}
// Remove removes a single entry from the store.
//
// Remove does nothing if key doesn't exist in the store.