diff options
author | Runxi Yu <me@runxiyu.org> | 2025-03-25 03:08:10 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-03-25 03:08:10 +0800 |
commit | 18156b8847eea535899247a573c1c4311ba9ae0a (patch) | |
tree | 24e81c508524056ab276f0defbec5dba0e68c59d /cache.go | |
parent | Fix group path trailing slash (diff) | |
download | forge-18156b8847eea535899247a573c1c4311ba9ae0a.tar.gz forge-18156b8847eea535899247a573c1c4311ba9ae0a.tar.zst forge-18156b8847eea535899247a573c1c4311ba9ae0a.zip |
Separate cache into separate files
Diffstat (limited to '')
-rw-r--r-- | cache.go | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/cache.go b/cache.go deleted file mode 100644 index 59c4004..0000000 --- a/cache.go +++ /dev/null @@ -1,74 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only -// SPDX-FileContributor: Runxi Yu <https://runxiyu.org> - -package main - -import ( - "html/template" - - "github.com/dgraph-io/ristretto/v2" - "go.lindenii.runxiyu.org/lindenii-common/clog" -) - -type treeReadmeCacheEntry struct { - DisplayTree []displayTreeEntry - ReadmeFilename string - ReadmeRendered template.HTML -} - -// key = commit hash + path -var treeReadmeCache *ristretto.Cache[[]byte, treeReadmeCacheEntry] - -func init() { - var err error - treeReadmeCache, err = ristretto.NewCache(&ristretto.Config[[]byte, treeReadmeCacheEntry]{ - NumCounters: 1e4, - MaxCost: 1 << 60, - BufferItems: 8192, - }) - if err != nil { - clog.Fatal(1, "Error initializing indexPageCache: "+err.Error()) - } -} - -var indexCommitsDisplayCache *ristretto.Cache[[]byte, []commitDisplay] - -func init() { - var err error - indexCommitsDisplayCache, err = ristretto.NewCache(&ristretto.Config[[]byte, []commitDisplay]{ - NumCounters: 1e4, - MaxCost: 1 << 60, - BufferItems: 8192, - }) - if err != nil { - clog.Fatal(1, "Error initializing indexCommitsCache: "+err.Error()) - } -} - -var commitPathFileHTMLCache *ristretto.Cache[[]byte, template.HTML] - -func init() { - var err error - commitPathFileHTMLCache, err = ristretto.NewCache(&ristretto.Config[[]byte, template.HTML]{ - NumCounters: 1e4, - MaxCost: 1 << 60, - BufferItems: 8192, - }) - if err != nil { - clog.Fatal(1, "Error initializing commitPathFileHTMLCache: "+err.Error()) - } -} - -var commitPathFileRawCache *ristretto.Cache[[]byte, string] - -func init() { - var err error - commitPathFileRawCache, err = ristretto.NewCache(&ristretto.Config[[]byte, string]{ - NumCounters: 1e4, - MaxCost: 1 << 60, - BufferItems: 8192, - }) - if err != nil { - clog.Fatal(1, "Error initializing commitPathFileRawCache: "+err.Error()) - } -} |