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

fix: expire cache items after 24h+ #669

Merged
merged 1 commit into from
Feb 13, 2024
Merged
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
5 changes: 3 additions & 2 deletions pkg/registry/ecr.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"encoding/base64"
"fmt"
"github.com/containers/image/v5/docker/reference"
"math/rand"
"net/http"
"os/exec"
"time"
Expand Down Expand Up @@ -159,7 +160,7 @@
}
}

e.cache.Set(name, "", 1)
e.cache.SetWithTTL(name, "", 1, time.Duration(24*time.Hour))

Check warning on line 163 in pkg/registry/ecr.go

View check run for this annotation

Codecov / codecov/patch

pkg/registry/ecr.go#L163

Added line #L163 was not covered by tests

return nil
}
Expand Down Expand Up @@ -256,7 +257,7 @@

log.Ctx(ctx).Trace().Str("ref", ref).Msg("found in target repository")

e.cache.Set(ref, "", 1)
e.cache.SetWithTTL(ref, "", 1, 24*time.Hour+time.Duration(rand.Intn(180))*time.Minute)

Check warning on line 260 in pkg/registry/ecr.go

View check run for this annotation

Codecov / codecov/patch

pkg/registry/ecr.go#L260

Added line #L260 was not covered by tests

return true
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/registry/gar.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"encoding/base64"
"encoding/json"
"fmt"
"math/rand"
"os/exec"
"strings"
"time"
Expand Down Expand Up @@ -152,7 +153,7 @@

log.Ctx(ctx).Trace().Str("ref", ref).Msg("found in target repository")

e.cache.Set(ref, "", 1)
e.cache.SetWithTTL(ref, "", 1, 24*time.Hour+time.Duration(rand.Intn(180))*time.Minute)

Check warning on line 156 in pkg/registry/gar.go

View check run for this annotation

Codecov / codecov/patch

pkg/registry/gar.go#L156

Added line #L156 was not covered by tests

return true
}
Expand Down
Loading