cache

package
v1.9.8 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(service Service, cacheDir string, opts ServeOptions) http.Handler

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 Manifest

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

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 ServeOptions

type ServeOptions struct {
	Host      string
	Port      int
	Root      string
	NoIndex   bool
	Version   string
	Token     string
	JSONLog   bool
	LogWriter io.Writer `json:"-"`
}

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