cache

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearAssetCache

func ClearAssetCache() error

ClearAssetCache removes cached assets for cleanup

func EnsureCacheDirs

func EnsureCacheDirs() error

EnsureCacheDirs creates all necessary cache directories

func GetArtifactCacheDir

func GetArtifactCacheDir() (string, error)

GetArtifactCacheDir is an alias for GetAssetCacheDir for backwards compatibility Deprecated: use GetAssetCacheDir instead

func GetAssetCacheDir

func GetAssetCacheDir() (string, error)

GetAssetCacheDir returns the directory for caching assets

func GetAssetCachePath

func GetAssetCachePath(name, version string) (string, error)

GetAssetCachePath returns the cache path for a specific asset

func GetCacheDir

func GetCacheDir() (string, error)

GetCacheDir returns the platform-specific cache directory for sx

func GetCachedLockFilePath

func GetCachedLockFilePath(repoURL string) (string, error)

GetCachedLockFilePath returns path for cached lock file

func GetGitRepoCachePath

func GetGitRepoCachePath(repoURL string) (string, error)

GetGitRepoCachePath returns the cache path for a git repository

func GetGitReposCacheDir

func GetGitReposCacheDir() (string, error)

GetGitReposCacheDir returns the directory for caching git repositories

func GetLockFileCacheDir

func GetLockFileCacheDir() (string, error)

GetLockFileCacheDir returns the directory for caching lock files

func GetLockFileETagPath

func GetLockFileETagPath(repoURL string) (string, error)

GetLockFileETagPath returns the path for storing lock file ETag

func GetTrackerCacheDir

func GetTrackerCacheDir() (string, error)

GetTrackerCacheDir returns the directory for tracking installed assets state

func GetTrackerCachePath

func GetTrackerCachePath(scopeKey string) (string, error)

GetTrackerCachePath returns the path for tracking installed assets scopeKey should be "global" or a hash/identifier for repo-scoped installs

func InvalidateLockFileCache added in v0.6.0

func InvalidateLockFileCache(repoURL string) error

InvalidateLockFileCache removes cached lock file and ETag for a repository URL This forces the next GetLockFile call to fetch fresh data from the backend

func LoadAssetFromDisk

func LoadAssetFromDisk(name, version string) ([]byte, error)

LoadAssetFromDisk loads a cached asset from disk

func LoadETag

func LoadETag(repoURL string) (string, error)

LoadETag loads the cached ETag for a lock file

func LoadLockFile

func LoadLockFile(repoURL string) ([]byte, error)

LoadLockFile loads cached lock file

func SaveAssetToDisk

func SaveAssetToDisk(name, version string, data []byte) error

SaveAssetToDisk caches an asset zip to disk

func SaveETag

func SaveETag(repoURL, etag string) error

SaveETag saves the ETag for a lock file

func SaveLockFile

func SaveLockFile(repoURL string, data []byte) error

SaveLockFile caches lock file to disk

Types

type ETagCache

type ETagCache struct {
	URL  string    `json:"url"`
	ETag string    `json:"etag"`
	Date time.Time `json:"date"`
}

ETagCache stores ETags for lock files

type SessionCache

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

SessionCache provides fast conversation/session ID tracking for clients that fire hooks on every prompt rather than once per session.

File format: Line-based, space-separated `session_id timestamp` Example:

668320d2-2fd8-4888-b33c-2a466fec86e7 2025-12-12T10:30:00Z
490b90b7-a2ce-4c2c-bb76-cb77b125df2f 2025-12-11T15:45:00Z

func NewSessionCache

func NewSessionCache(clientID string) (*SessionCache, error)

NewSessionCache creates a session cache for the given client ID

func (*SessionCache) Clear

func (s *SessionCache) Clear() error

Clear removes all session entries.

func (*SessionCache) CullOldEntries

func (s *SessionCache) CullOldEntries(maxAge time.Duration) error

CullOldEntries removes entries older than the specified max age. This keeps the session file from growing indefinitely.

func (*SessionCache) FilePath

func (s *SessionCache) FilePath() string

FilePath returns the path to the session cache file (for testing/debugging).

func (*SessionCache) HasSession

func (s *SessionCache) HasSession(sessionID string) bool

HasSession checks if a session ID has been seen before. This is optimized for fast checks (~1ms) by scanning the file line by line.

func (*SessionCache) RecordSession

func (s *SessionCache) RecordSession(sessionID string) error

RecordSession records a session ID with the current timestamp. Should be called optimistically before installation starts.

Jump to

Keyboard shortcuts

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