Documentation
¶
Overview ¶
Copyright 2022-2026 Reto Gantenbein SPDX-License-Identifier: Apache-2.0
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheConfig ¶
type FileCache ¶
type FileCache interface {
// Create a temp file in the cache directory for the given URI, suitable
// for streaming writes. Creates parent directories and validates path
// traversal. The caller is responsible for closing the returned file.
CreateTempWriter(uri string) (*os.File, error)
// Atomically commit a temp file into the cache by setting its mtime
// and renaming it to the final path for the given URI. Trusts that
// the URI was already validated by CreateTempWriter.
CommitTempFile(tmpPath string, uri string, mtime time.Time) error
// Remove cached file for given URL
DeleteFile(string) error
// Return file system path to cached file for given URL. If the URL points
// to a path outside the cache directory return an error.
GetFilePath(string) (string, error)
// Returns a list of file suffixes that will be cached
GetFileSuffixes() []string
// Return if URL is supposed to be cached
IsCacheCandidate(string) bool
// Return if file exists in cache for given URL
IsCached(string) bool
// Save buffer as file in cache for given URL
SaveToDisk(string, *bytes.Buffer, time.Time) error
}
func New ¶
func New(cfg *CacheConfig) FileCache
Click to show internal directories.
Click to hide internal directories.