MCPcopy Create free account
hub / github.com/PostHog/duckgres / NewDiskCache

Function NewDiskCache

cmd/cache-proxy/cache.go:91–130  ·  view source on GitHub ↗

NewDiskCache creates a cache backed by the given directory. maxPercent is the percentage of filesystem capacity to use (e.g. 80).

(dir string, maxPercent int)

Source from the content-addressed store, hash-verified

89 cacheEntryLimitReason = promauto.NewGaugeVec(prometheus.GaugeOpts{
90 Name: "cache_proxy_cache_entry_limit_reason",
91 Help: "Future derived entry-limit bottleneck; exactly one of disk or metadata is 1",
92 }, []string{"reason"})
93 cacheEvictionsTotal = promauto.NewCounter(prometheus.CounterOpts{
94 Name: "cache_proxy_evictions_total",
95 Help: "Number of LRU cache evictions",
96 })
97 cacheEvictionsByPhaseReasonTotal = promauto.NewCounterVec(prometheus.CounterOpts{
98 Name: "cache_proxy_evictions_by_phase_reason_total",
99 Help: "Committed cache-entry evictions by bounded phase and pressure reason",
100 }, []string{"phase", "reason"})
101 cacheStartupScanDuration = promauto.NewHistogram(prometheus.HistogramOpts{
102 Name: "cache_proxy_cache_startup_scan_duration_seconds",
103 Help: "Duration of cache startup scans",
104 })
105 cacheStartupScanFilesInspectedTotal = promauto.NewCounter(prometheus.CounterOpts{
106 Name: "cache_proxy_cache_startup_scan_files_inspected_total",
107 Help: "Directory entries inspected during cache startup scans",
108 })
109 cacheStartupInvalidFilesTotal = promauto.NewCounter(prometheus.CounterOpts{
110 Name: "cache_proxy_cache_startup_invalid_files_total",
111 Help: "Invalid or unrelated root-directory entries excluded from cache ownership during startup scans",
112 })
113 cacheTemporaryFilesRemovedTotal = promauto.NewCounter(prometheus.CounterOpts{
114 Name: "cache_proxy_cache_temporary_files_removed_total",
115 Help: "Incomplete temporary cache files removed during startup cleanup",
116 })
117)
118
119type cacheEvictionPhase = string
120
121const (
122 cacheEvictionPhaseStartup cacheEvictionPhase = "startup"
123 cacheEvictionPhaseBackground cacheEvictionPhase = "background"
124 cacheEvictionPhaseRequest cacheEvictionPhase = "request"
125)
126
127type cacheEvictionReason = string
128
129const (
130 cacheEvictionReasonEntry cacheEvictionReason = "entry"
131 cacheEvictionReasonByte cacheEvictionReason = "byte"
132)
133

Callers 2

mainFunction · 0.85
newTestCacheFunction · 0.85

Calls 1

scanExistingMethod · 0.95

Tested by 1

newTestCacheFunction · 0.68