Fix - default disk cache size

The default disk cache size is 100mb. Changed the default disk cache to
10gb.
This commit is contained in:
naveen 2021-02-22 17:19:26 -05:00 committed by Naveen
parent db81680172
commit 9510d3e0d7
3 changed files with 7 additions and 4 deletions

View File

@ -61,10 +61,10 @@ ci-e2e: ## Runs ci e2e tests
ci-e2e: build check-env
$(call ndef, GITHUB_AUTH_TOKEN)
mkdir -p bin
./scorecard --repo=https://github.com/ossf/scorecard --format json > ./bin/results.json
./scorecard --repo=https://github.com/ossf/scorecard --show-details --format json > ./bin/results.json
ginkgo -p -v -cover ./...
mkdir -p cache
USE_DISK_CACHE=1 DISK_CACHE_PATH="./cache" ./scorecard --repo=https://github.com/ossf/scorecard --format json > ./bin/results.json
USE_DISK_CACHE=1 DISK_CACHE_PATH="./cache" ./scorecard --repo=https://github.com/ossf/scorecard --show-details --format json > ./bin/results.json
ginkgo -p -v -cover ./...

1
go.mod
View File

@ -11,6 +11,7 @@ require (
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/onsi/ginkgo v1.15.0
github.com/onsi/gomega v1.10.5
github.com/peterbourgon/diskv v2.0.1+incompatible
github.com/pkg/errors v0.9.1
github.com/shurcooL/githubv4 v0.0.0-20200928013246-d292edc3691b
github.com/shurcooL/graphql v0.0.0-20200928012149-18c5c3165e3a // indirect

View File

@ -27,6 +27,7 @@ import (
"github.com/bradleyfalzon/ghinstallation"
cache "github.com/naveensrinivasan/httpcache"
"github.com/naveensrinivasan/httpcache/diskcache"
"github.com/peterbourgon/diskv"
"github.com/pkg/errors"
"go.uber.org/zap"
"golang.org/x/oauth2"
@ -89,10 +90,11 @@ func NewTransport(ctx context.Context, logger *zap.SugaredLogger) http.RoundTrip
Logger: logger,
InnerTransport: transport,
}
const cacheSize uint64 = 10000 * 1024 * 1024 // 10gb
// uses the disk cache
if cachePath, useDisk := shouldUseDiskCache(); useDisk {
c := cache.NewTransport(diskcache.New(cachePath))
c := cache.NewTransport(diskcache.NewWithDiskv(
diskv.New(diskv.Options{BasePath: cachePath, CacheSizeMax: cacheSize})))
c.Transport = rateLimit
return c
}