Skip to content

Commit

Permalink
Revise caching strategy (PR-8) manual merge
Browse files Browse the repository at this point in the history
  • Loading branch information
liamfallon committed Nov 11, 2024
1 parent a69870d commit 98115d4
Show file tree
Hide file tree
Showing 10 changed files with 358 additions and 253 deletions.
21 changes: 17 additions & 4 deletions pkg/cache/memory/draft.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package memory

import (
"context"
"fmt"

"github.com/nephio-project/porch/api/porch/v1alpha1"
"github.com/nephio-project/porch/pkg/cache"
Expand All @@ -38,8 +39,9 @@ func (cd *cachedDraft) Close(ctx context.Context, version string) (repository.Pa
if err != nil {
return nil, err
}

if v != cd.cache.lastVersion {
_, _, err = cd.cache.refreshAllCachedPackages(ctx)
err = cd.cache.reconcileCache(ctx, "draft-version")
if err != nil {
return nil, err
}
Expand All @@ -64,9 +66,20 @@ func (cd *cachedDraft) Close(ctx context.Context, version string) (repository.Pa
return nil, err
}

if closed, err := cd.PackageDraft.Close(ctx, nextVersion); err != nil {
closed, err := cd.PackageDraft.Close(ctx, nextVersion)
if err != nil {
return nil, err
} else {
return cd.cache.update(ctx, closed)
}

err = cd.cache.reconcileCache(ctx, "close-draft")
if err != nil {
return nil, err
}

cpr := cd.cache.getPackageRevision(closed.Key())
if cpr == nil {
return nil, fmt.Errorf("closed draft not found")
}

return cpr, nil
}
Loading

0 comments on commit 98115d4

Please sign in to comment.