Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileCache ¶
type FileCache struct {
// contains filtered or unexported fields
}
FileCache is a file-based LRU cache. It tracks files in memory and evicts the least recently used when count or total size limits are exceeded.
func (*FileCache) Get ¶
Get reads data from the cache and promotes the entry to most recently used. Returns (nil, false) on cache miss or read error. Nil-safe: calling Get on a nil *FileCache always returns (nil, false).
func (*FileCache) Has ¶ added in v0.19.1037
Has reports whether an entry is currently tracked and promotes it to most recently used. It does not read the file from disk, so it is cheaper than Get when only presence matters. A tracked entry implies the data was previously written to durable storage, so callers can safely skip re-uploading. Nil-safe: calling Has on a nil *FileCache returns false.
func (*FileCache) Len ¶
Len returns the number of entries currently in the cache. Nil-safe: calling Len on a nil *FileCache returns 0.
type Options ¶
type Options struct {
// Dir is the directory where cache files are stored.
// Created if it does not exist.
Dir string
// MaxCount is the maximum number of files in the cache.
// When exceeded, the least recently used files are evicted.
MaxCount int
// MaxBytes is the maximum total size in bytes of all cached files.
// When exceeded, the least recently used files are evicted.
MaxBytes int64
}