Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: depracted cache invalidate func and add slower but more reliable one #78

Merged
merged 1 commit into from
May 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading