From 99bdcca183cef952a67c709afefc32564b1ee6ab Mon Sep 17 00:00:00 2001 From: Alex Saveliev Date: Mon, 14 Oct 2024 16:33:59 +0300 Subject: [PATCH] fix(chore): allow to delete keys by regex (#556) --- pkg/api/souin.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/api/souin.go b/pkg/api/souin.go index c57393d4d..a14671b2a 100644 --- a/pkg/api/souin.go +++ b/pkg/api/souin.go @@ -105,8 +105,13 @@ func (s *SouinAPI) BulkDelete(key string, purge bool) { // Delete will delete a record into the provider cache system and will update the Souin API if enabled // The key can be a regexp to delete multiple items func (s *SouinAPI) Delete(key string) { + _, err := regexp.Compile(key) for _, current := range s.storers { - current.Delete(key) + if err != nil { + current.DeleteMany(key) + } else { + current.Delete(key) + } } }