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

Revise caching strategy #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
18 changes: 15 additions & 3 deletions pkg/cache/draft.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package cache

import (
"context"
"fmt"

"github.com/nephio-project/porch/pkg/repository"
)
Expand All @@ -28,9 +29,20 @@ type cachedDraft struct {
var _ repository.PackageDraft = &cachedDraft{}

func (cd *cachedDraft) Close(ctx context.Context) (repository.PackageRevision, error) {
if closed, err := cd.PackageDraft.Close(ctx); err != nil {
closed, err := cd.PackageDraft.Close(ctx)
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