Skip to content

Commit

Permalink
chore: depracted cache invalidate func and add slower but more reliab…
Browse files Browse the repository at this point in the history
…le one (#78)
  • Loading branch information
prgres authored May 19, 2024
1 parent 846a264 commit 84444e0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkg/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,32 @@ func (c *Cache) Invalidate() error {
// Clear the in-memory cache
c.data = make(map[string]Data)

contents, err := filepath.Glob(c.path + "/*")
if err != nil {
return err
}

for _, item := range contents {
if strings.Contains(item, ".gitkeep") {
continue
}

c.logger.Debug("Removing:", "path", item)

if err = os.RemoveAll(item); err != nil {
return err
}
}

return nil
}

func (c *Cache) Invalidate_Deprecated() error {
c.logger.Debug("Invalidating all cache entries")

// Clear the in-memory cache
c.data = make(map[string]Data)

// Remove subdirectories and nested files within the cache directory
subdirs, err := os.ReadDir(c.path)
if err != nil {
Expand Down

0 comments on commit 84444e0

Please sign in to comment.