cache

package
v1.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadHandler added in v1.11.0

func DownloadHandler(service Service, cacheDir string, opts MachineOptions) http.HandlerFunc

DownloadHandler serves /download/<path-md5 key>, the protocol eget clients use to fetch a cached file by content path.

func FileHandler added in v1.11.0

func FileHandler(service Service, cacheDir string, opts MachineOptions) http.HandlerFunc

FileHandler serves /files/<relative path> for direct browsing.

func ManifestHandler added in v1.11.0

func ManifestHandler(service Service, cacheDir string, opts MachineOptions) http.HandlerFunc

ManifestHandler serves the cache manifest at /manifest.json.

func ParseOlderDuration

func ParseOlderDuration(value string) (time.Duration, error)

func ValidRoot

func ValidRoot(root string) bool

Types

type CacheMirrorStatus added in v1.7.5

type CacheMirrorStatus struct {
	Enable   bool   `json:"enable"`
	URL      string `json:"url,omitempty"`
	Timeout  int    `json:"timeout,omitempty"`
	Fallback bool   `json:"fallback"`
}

type CacheScanOptions

type CacheScanOptions struct {
	Kinds []Kind
	Root  string
}

type CleanOptions

type CleanOptions struct {
	Older      time.Duration
	All        bool
	DryRun     bool
	Yes        bool
	KeepLatest bool
	Kinds      []Kind
}

type CleanResult

type CleanResult struct {
	CacheDir          string      `json:"cache_dir"`
	MatchedFiles      int         `json:"matched_files"`
	RemovedFiles      int         `json:"removed_files"`
	MatchedSize       int64       `json:"matched_size"`
	RemovedSize       int64       `json:"removed_size"`
	KeptLatestFiles   int         `json:"kept_latest_files"`
	UnrecognizedFiles int         `json:"unrecognized_files"`
	Skipped           []CleanSkip `json:"skipped"`
	// contains filtered or unexported fields
}

func (CleanResult) NeedsConfirmation

func (r CleanResult) NeedsConfirmation() bool

type CleanSkip

type CleanSkip struct {
	Path   string `json:"path"`
	Reason string `json:"reason"`
}

type Entry

type Entry struct {
	Kind      Kind
	Path      string
	RelPath   string
	Size      int64
	ModTime   time.Time
	IsPartial bool
	IsSymlink bool
	// contains filtered or unexported fields
}

type Kind

type Kind string
const (
	KindPkg      Kind = "pkg"
	KindAPI      Kind = "api"
	KindSDK      Kind = "sdk"
	KindSDKIndex Kind = "sdk-index"
	KindPartial  Kind = "partial"
)

type KindSummary added in v1.7.5

type KindSummary struct {
	Files int   `json:"files"`
	Size  int64 `json:"size"`
}

type ListFile added in v1.7.5

type ListFile struct {
	Kind    Kind      `json:"kind"`
	Path    string    `json:"path"`
	PathKey string    `json:"path_key,omitempty"`
	Size    int64     `json:"size"`
	ModTime time.Time `json:"mod_time"`
}

type ListOptions added in v1.7.5

type ListOptions struct {
	Root string
}

type ListResult added in v1.7.5

type ListResult struct {
	CacheDir   string     `json:"cache_dir"`
	Root       string     `json:"root"`
	TotalFiles int        `json:"total_files"`
	TotalSize  int64      `json:"total_size"`
	Files      []ListFile `json:"files"`
}

type MachineOptions added in v1.11.0

type MachineOptions struct {
	Root    string
	NoIndex bool
	Version string
}

MachineOptions configures the machine endpoints (/manifest.json, /download/*, /files/*). Authentication is the caller's job: `eget web` wraps these handlers with its own token middleware, so no token lives here.

type Manifest

type Manifest struct {
	Schema int            `json:"schema"`
	Server ManifestServer `json:"server"`
	Cache  ManifestCache  `json:"cache"`
	Files  []ManifestFile `json:"files"`
}

Manifest is the JSON cache index eget clients use as a cache mirror source.

type ManifestCache

type ManifestCache struct {
	Root        string    `json:"root"`
	GeneratedAt time.Time `json:"generated_at"`
}

type ManifestFile

type ManifestFile struct {
	Kind    string    `json:"kind"`
	Path    string    `json:"path"`
	PathKey string    `json:"path_key,omitempty"`
	URL     string    `json:"url"`
	Size    int64     `json:"size"`
	ModTime time.Time `json:"mod_time"`
}

type ManifestServer

type ManifestServer struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	BaseURL string `json:"base_url"`
}

type Service

type Service struct {
	Config *cfgpkg.File
	Now    func() time.Time
}

func (Service) ApplyClean added in v1.9.0

func (s Service) ApplyClean(preview CleanResult) (CleanResult, error)

ApplyClean removes only unchanged files captured by PreviewClean.

func (Service) Clean

func (s Service) Clean(cacheDir string, opts CleanOptions) (CleanResult, error)

func (Service) List added in v1.7.5

func (s Service) List(cacheDir string, opts ListOptions) (ListResult, error)

func (Service) PreviewClean

func (s Service) PreviewClean(cacheDir string, opts CleanOptions) (CleanResult, error)

func (Service) ResolveCacheDir

func (s Service) ResolveCacheDir() (string, error)

func (Service) Scan

func (s Service) Scan(cacheDir string, opts CacheScanOptions) ([]Entry, error)

func (Service) Status added in v1.7.5

func (s Service) Status(cacheDir string) (StatusResult, error)

type StatusResult added in v1.7.5

type StatusResult struct {
	CacheDir     string                 `json:"cache_dir"`
	GeneratedAt  time.Time              `json:"generated_at"`
	TotalFiles   int                    `json:"total_files"`
	TotalSize    int64                  `json:"total_size"`
	Kinds        map[string]KindSummary `json:"kinds"`
	ServeCommand string                 `json:"serve_command"`
	CacheMirror  CacheMirrorStatus      `json:"cache_mirror"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL