workaround for cache invalidation

This commit is contained in:
Niklas 2021-08-16 22:40:10 +02:00
parent 65739c9307
commit c84f94372e

View File

@ -6,6 +6,7 @@ import (
"path/filepath"
"github.com/graph-gophers/dataloader"
log "github.com/sirupsen/logrus"
)
func invalidateCache(ctx context.Context, id string) error {
@ -14,10 +15,15 @@ func invalidateCache(ctx context.Context, id string) error {
return fmt.Errorf("Failed to get loader from context")
}
log.Debug("Invalidate cache for id: ", id)
loader["getFile"].Clear(ctx, dataloader.StringKey(id))
loader["listObjects"].Clear(ctx, dataloader.StringKey(id))
loader["getFiles"].Clear(ctx, dataloader.StringKey(getPathFromId(id)))
// FIXME: this is the only way i can invalidate the cache without it breaking stuff
// loader["listObjects"].Clear(ctx, dataloader.StringKey(id))
loader["listObjects"].ClearAll()
return nil
}