Documentation
¶
Index ¶
- Constants
- Variables
- func ByteRangeCovered(ranges []ByteRange, requested ByteRange) (bool, error)
- func ByteRangesCoverFile(ranges []ByteRange, fileSize int64) (bool, error)
- type ByteRange
- type EntryMetadata
- func (m EntryMetadata) CachedByteCount() (int64, error)
- func (m EntryMetadata) IsComplete() bool
- func (m EntryMetadata) Matches(other EntryMetadata) bool
- func (m EntryMetadata) SameContent(other EntryMetadata) bool
- func (m EntryMetadata) Validate() error
- func (m EntryMetadata) WithCompleteRange() (EntryMetadata, error)
- func (m EntryMetadata) WithRanges(ranges []ByteRange) (EntryMetadata, error)
- type Stats
Constants ¶
const EntryMetadataVersion = 2
Variables ¶
var ( ErrInvalidByteRange = errors.New("invalid byte range") ErrSparseFilesUnsupported = errors.New("sparse files are not supported by the cache volume") )
var ErrInvalidEntryMetadata = errors.New("invalid cache entry metadata")
Functions ¶
func ByteRangeCovered ¶ added in v3.3.285
ByteRangeCovered reports whether ranges completely cover requested.
Types ¶
type ByteRange ¶ added in v3.3.285
ByteRange identifies a half-open range of bytes: [Start, End).
func MissingByteRanges ¶ added in v3.3.285
MissingByteRanges returns the parts of requested that ranges do not cover.
func NormalizeByteRanges ¶ added in v3.3.285
NormalizeByteRanges sorts ranges and merges ranges that overlap or touch. Empty ranges are omitted. The input slice is not modified.
type EntryMetadata ¶ added in v3.3.109
type EntryMetadata struct {
Version int `json:"version"`
Path string `json:"path"`
Size int64 `json:"size"`
ModTime time.Time `json:"mtime"`
ETag string `json:"etag,omitempty"`
Ranges []ByteRange `json:"ranges"`
}
EntryMetadata identifies cached ranges for a specific remote file version.
func NewEntryMetadata ¶ added in v3.3.109
func NewEntryMetadata(path string, size int64, modTime time.Time) EntryMetadata
func (EntryMetadata) CachedByteCount ¶ added in v3.3.285
func (m EntryMetadata) CachedByteCount() (int64, error)
CachedByteCount returns the number of valid bytes represented by the ranges.
func (EntryMetadata) IsComplete ¶ added in v3.3.285
func (m EntryMetadata) IsComplete() bool
IsComplete reports whether the valid ranges cover the complete file.
func (EntryMetadata) Matches ¶ added in v3.3.109
func (m EntryMetadata) Matches(other EntryMetadata) bool
Matches compares the listing identity. HTTP validators are checked separately because callers looking up cached bytes have only listing metadata.
func (EntryMetadata) SameContent ¶ added in v3.3.285
func (m EntryMetadata) SameContent(other EntryMetadata) bool
SameContent also requires the HTTP validator to match before merging bytes.
func (EntryMetadata) Validate ¶ added in v3.3.285
func (m EntryMetadata) Validate() error
Validate checks the schema version, file size, and normalized range list.
func (EntryMetadata) WithCompleteRange ¶ added in v3.3.285
func (m EntryMetadata) WithCompleteRange() (EntryMetadata, error)
WithCompleteRange returns metadata covering the complete file.
func (EntryMetadata) WithRanges ¶ added in v3.3.285
func (m EntryMetadata) WithRanges(ranges []ByteRange) (EntryMetadata, error)
WithRanges returns metadata with a validated, normalized range list.
type Stats ¶
type Stats struct {
CapacityBytes int64
CapacityBytesRemaining int64
MaxFileCount int64
FileCountRemaining int64
FileCount atomic.Int64
ReadBytes atomic.Int64
ReadCount atomic.Int64
SizeBytes atomic.Int64
WriteBytes atomic.Int64
WriteCount atomic.Int64
LoadDuration time.Duration
LruCount int
PinnedCount int
PinnedPaths map[string]int
LruKeys []string
}
Stats maintains statistics about cache usage. In non-debug builds, this type exists but has no methods for retrieving statistics.
func (*Stats) ResetCounters ¶
func (st *Stats) ResetCounters()
ResetCounters sets "counter" type stats to zero.