Commit cd04225d authored by João Pereira's avatar João Pereira 🔴 Committed by Hayley Swimelar
Browse files

feat: bump root repository size cache TTL to 5m

parent aec520db
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ const (
	greaterThan = ">"

	// sizeWithDescendantsKeyTTL is the TTL for the cached value of the "size with descendants" for a given repository.
	sizeWithDescendantsKeyTTL = 2 * time.Minute
	sizeWithDescendantsKeyTTL = 5 * time.Minute
)

// FilterParams contains the specific filters used to get
@@ -1740,13 +1740,14 @@ func (s *repositoryStore) SizeWithDescendants(ctx context.Context, r *models.Rep
		return RepositorySize{bytes: b}, err
	}

	if found, b := s.cache.GetSizeWithDescendants(ctx, r); found {
		return RepositorySize{b, true}, nil
	}

	if s.cache.HasSizeWithDescendantsTimedOut(ctx, r) {
		return RepositorySize{}, ErrSizeHasTimedOut
	}

	if found, b := s.cache.GetSizeWithDescendants(ctx, r); found {
		return RepositorySize{b, true}, nil
	}
	b, err := s.topLevelSizeWithDescendants(ctx, r)
	if err != nil {
		var pgErr *pgconn.PgError
+1 −0
Original line number Diff line number Diff line
@@ -290,6 +290,7 @@ func (h *repositoryHandler) GetRepository(w http.ResponseWriter, r *http.Request
			"is_top_level": repo.IsTopLevel(),
			"root_repo":    repo.TopLevelPathSegment(),
			"precision":    precision,
			"failure":      err != nil,
		}).Info("repository size measurement")
		if err != nil {
			h.Errors = append(h.Errors, errcode.FromUnknownError(err))