Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'internal/vfs/zip/vfs.go')
-rw-r--r--internal/vfs/zip/vfs.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/internal/vfs/zip/vfs.go b/internal/vfs/zip/vfs.go
index feeab974..d90d4796 100644
--- a/internal/vfs/zip/vfs.go
+++ b/internal/vfs/zip/vfs.go
@@ -15,6 +15,18 @@ import (
"gitlab.com/gitlab-org/gitlab-pages/metrics"
)
+const (
+ // we assume that each item costs around 100 bytes
+ // this gives around 5MB of raw memory needed without acceleration structures
+ defaultDataOffsetItems = 50000
+ defaultDataOffsetExpirationInterval = time.Hour
+
+ // we assume that each item costs around 200 bytes
+ // this gives around 2MB of raw memory needed without acceleration structures
+ defaultReadlinkItems = 10000
+ defaultReadlinkExpirationInterval = time.Hour
+)
+
var (
errAlreadyCached = errors.New("archive already cached")
)
@@ -52,8 +64,8 @@ func New(cfg *config.ZipServing) vfs.VFS {
})
// TODO: To be removed with https://gitlab.com/gitlab-org/gitlab-pages/-/issues/480
- zipVFS.dataOffsetCache = newLruCache("data-offset", cfg.DataOffsetItems, cfg.DataOffsetExpirationInterval)
- zipVFS.readlinkCache = newLruCache("readlink", cfg.ReadlinkItems, cfg.ReadlinkExpirationInterval)
+ zipVFS.dataOffsetCache = newLruCache("data-offset", defaultDataOffsetItems, defaultDataOffsetExpirationInterval)
+ zipVFS.readlinkCache = newLruCache("readlink", defaultReadlinkItems, defaultReadlinkExpirationInterval)
return zipVFS
}