system

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCacheNotFound = errors.New("cache item not found")

ErrCacheNotFound is returned when a cache item cannot be found

Functions

func CloseCaches

func CloseCaches() error

CloseCaches closes all tracked caches collecting the first error if multiple occur. It is safe to call multiple times; subsequent calls will no-op as the slice is cleared.

func CopyFiles

func CopyFiles(currentPath string, targetPath string) error

func ExpandEnv

func ExpandEnv(s string) string

func GetHeyFrameCliCacheDir

func GetHeyFrameCliCacheDir() string

GetHeyFrameCliCacheDir returns the base cache directory for heyframe-c

func GetInstalledNodeVersion

func GetInstalledNodeVersion(ctx context.Context) (string, error)

GetInstalledNodeVersion checks the installed Node.js version on the system.

func GetInstalledPHPVersion

func GetInstalledPHPVersion(ctx context.Context) (string, error)

GetInstalledPHPVersion checks the installed PHP version on the system.

func IsNodeVersionAtLeast

func IsNodeVersionAtLeast(ctx context.Context, requiredVersion string) (bool, error)

IsNodeVersionAtLeast checks if the installed Node.js version meets the minimum required version.

func IsPHPVersionAtLeast

func IsPHPVersionAtLeast(ctx context.Context, requiredVersion string) (bool, error)

Types

type Cache

type Cache interface {
	// Get retrieves a cached item by key. Returns ErrCacheNotFound if not found.
	Get(ctx context.Context, key string) (io.ReadCloser, error)

	// Set stores an item in the cache with the given key
	Set(ctx context.Context, key string, data io.Reader) error

	// GetFilePath returns a file path for direct access to the cached item.
	// For local caches, this returns the actual file path.
	// For remote caches, this downloads the item to a temp file and returns that path.
	// Returns ErrCacheNotFound if the item doesn't exist.
	GetFilePath(ctx context.Context, key string) (string, error)

	// StoreFolderCache stores an entire folder structure in the cache with the given key.
	// The folderPath should be the root directory to cache.
	StoreFolderCache(ctx context.Context, key string, folderPath string) error

	// GetFolderCachePath returns a folder path for direct access to the cached folder.
	// For local caches, this returns the actual folder path.
	// For remote caches, this downloads and extracts the folder to a temp directory.
	// Returns ErrCacheNotFound if the folder doesn't exist.
	GetFolderCachePath(ctx context.Context, key string) (string, error)

	// RestoreFolderCache extracts/copies a cached folder to the specified target directory.
	// This is useful when you want to restore cached content to a specific location.
	// Returns ErrCacheNotFound if the cached folder doesn't exist.
	RestoreFolderCache(ctx context.Context, key string, targetPath string) error

	// Close cleans up any temporary files or resources held by the cache
	Close() error
}

Cache provides a unified interface for caching operations

func GetCacheWithPrefix

func GetCacheWithPrefix(prefix string) Cache

GetCacheWithPrefix returns a cache instance with a custom prefix using the factory

func GetDefaultCache

func GetDefaultCache() Cache

GetDefaultCache returns a default cache instance using the factory

type CacheFactory

type CacheFactory interface {
	CreateCache() Cache
}

CacheFactory creates cache instances based on the environment

type DefaultCacheFactory

type DefaultCacheFactory struct{}

DefaultCacheFactory implements CacheFactory

func NewCacheFactory

func NewCacheFactory() *DefaultCacheFactory

NewCacheFactory creates a new cache factory

func (*DefaultCacheFactory) CreateCache

func (f *DefaultCacheFactory) CreateCache() Cache

CreateCache creates a cache instance based on the environment

func (*DefaultCacheFactory) CreateCacheWithPrefix

func (f *DefaultCacheFactory) CreateCacheWithPrefix(prefix string) Cache

CreateCacheWithPrefix creates a cache instance with a custom prefix/directory

type DiskCache

type DiskCache struct {
	// contains filtered or unexported fields
}

DiskCache implements Cache interface using local filesystem

func NewDiskCache

func NewDiskCache(basePath string) *DiskCache

NewDiskCache creates a new disk-based cache

func (*DiskCache) Close

func (c *DiskCache) Close() error

Close cleans up any resources (no-op for disk cache)

func (*DiskCache) Get

func (c *DiskCache) Get(ctx context.Context, key string) (io.ReadCloser, error)

Get retrieves a cached item by key

func (*DiskCache) GetFilePath

func (c *DiskCache) GetFilePath(ctx context.Context, key string) (string, error)

GetFilePath returns the file path for direct access to the cached item

func (*DiskCache) GetFolderCachePath

func (c *DiskCache) GetFolderCachePath(ctx context.Context, key string) (string, error)

GetFolderCachePath returns the folder path for direct access to the cached folder

func (*DiskCache) RestoreFolderCache

func (c *DiskCache) RestoreFolderCache(ctx context.Context, key string, targetPath string) error

RestoreFolderCache copies a cached folder to the specified target directory

func (*DiskCache) Set

func (c *DiskCache) Set(ctx context.Context, key string, data io.Reader) error

Set stores an item in the cache with the given key

func (*DiskCache) StoreFolderCache

func (c *DiskCache) StoreFolderCache(ctx context.Context, key string, folderPath string) error

StoreFolderCache stores an entire folder structure in the cache

type GitHubActionsCache

type GitHubActionsCache struct {
	// contains filtered or unexported fields
}

GitHubActionsCache implements Cache interface using GitHub Actions cache

func NewGitHubActionsCache

func NewGitHubActionsCache(prefix string) (*GitHubActionsCache, error)

NewGitHubActionsCache creates a new GitHub Actions cache

func (*GitHubActionsCache) Close

func (c *GitHubActionsCache) Close() error

Close cleans up all temporary files created by GetFilePath

func (*GitHubActionsCache) Get

Get retrieves a cached item by key

func (*GitHubActionsCache) GetFilePath

func (c *GitHubActionsCache) GetFilePath(ctx context.Context, key string) (string, error)

GetFilePath downloads the cache item to a temporary file and returns the file path

func (*GitHubActionsCache) GetFolderCachePath

func (c *GitHubActionsCache) GetFolderCachePath(ctx context.Context, key string) (string, error)

GetFolderCachePath downloads and extracts the cached folder to a temporary directory

func (*GitHubActionsCache) RestoreFolderCache

func (c *GitHubActionsCache) RestoreFolderCache(ctx context.Context, key string, targetPath string) error

RestoreFolderCache downloads and extracts a cached folder to the specified target directory

func (*GitHubActionsCache) Set

func (c *GitHubActionsCache) Set(ctx context.Context, key string, data io.Reader) error

Set stores an item in the cache with the given key

func (*GitHubActionsCache) StoreFolderCache

func (c *GitHubActionsCache) StoreFolderCache(ctx context.Context, key string, folderPath string) error

StoreFolderCache stores an entire folder structure in the cache

Jump to

Keyboard shortcuts

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