aboutsummaryrefslogtreecommitdiff
path: root/cache_commit_path_file_html.go
blob: 9254d6b8ba85c26331ca9e4147f524b66029dafd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

// SPDX-License-Identifier: AGPL-3.0-only
// SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org>

package main

import (
	"html/template"

	"github.com/dgraph-io/ristretto/v2"
	"go.lindenii.runxiyu.org/lindenii-common/clog"
)

// The key is the commit ID raw hash, followed by the file path.
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())
	}
}