cache

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package cache provides domain logic for cache management operations including clearing directories, gathering cache information, and formatting byte sizes.

Index

Constants

This section is empty.

Variables

ValidKinds lists all valid cache kinds.

Functions

func ClearDirectory

func ClearDirectory(dir, pattern string) (int64, int64, error)

ClearDirectory removes files from a directory, optionally matching a pattern. Returns the number of files removed and total bytes reclaimed.

func FormatBytes

func FormatBytes(bytes int64) string

FormatBytes formats bytes as a human-readable string.

Types

type ClearOutput

type ClearOutput struct {
	RemovedFiles int64  `json:"removedFiles" yaml:"removedFiles"`
	RemovedBytes int64  `json:"removedBytes" yaml:"removedBytes"`
	RemovedHuman string `json:"reclaimedHuman" yaml:"reclaimedHuman"`
	Kind         string `json:"kind,omitempty" yaml:"kind,omitempty"`
	Name         string `json:"name,omitempty" yaml:"name,omitempty"`
}

ClearOutput represents the result of a cache clear operation.

type Info

type Info struct {
	Name        string `json:"name" yaml:"name"`
	Path        string `json:"path" yaml:"path"`
	Size        int64  `json:"size" yaml:"size"`
	SizeHuman   string `json:"sizeHuman" yaml:"sizeHuman"`
	FileCount   int64  `json:"fileCount" yaml:"fileCount"`
	Description string `json:"description" yaml:"description"`
}

Info represents information about a cache directory.

func GetCacheInfo

func GetCacheInfo(name, dir, description string) Info

GetCacheInfo returns information about a cache directory.

type InfoOutput

type InfoOutput struct {
	Caches     []Info `json:"caches" yaml:"caches"`
	TotalSize  int64  `json:"totalSize" yaml:"totalSize"`
	TotalHuman string `json:"totalHuman" yaml:"totalHuman"`
	TotalFiles int64  `json:"totalFiles" yaml:"totalFiles"`
}

InfoOutput represents aggregated information for multiple cache directories.

type Kind

type Kind string

Kind represents the type of cache to clear.

const (
	// KindAll clears all caches.
	KindAll Kind = "all"
	// KindHTTP clears the HTTP response cache.
	KindHTTP Kind = "http"
	// KindBuild clears the build cache (incremental build fingerprints).
	KindBuild Kind = "build"
)

Jump to

Keyboard shortcuts

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