filecache

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 9 Imported by: 7

Documentation

Overview

Package filecache provides shared on-disk caching helpers for matcher, analyzer, and detector implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultDir added in v0.17.0

func DefaultDir(parts ...string) (string, error)

DefaultDir returns the directory a component's cache lives in by default, ~/.bomly/cache/<parts...>, for example DefaultDir("licenses", "depsdev"). It is the one place that location is built, so every component caches under the same root and the access a plugin declares ("home") stays true.

When the user's home directory cannot be determined, DefaultDir returns an error rather than a relative path. A relative fallback lands in whatever directory Bomly happens to run in, which no access declaration describes (bomly-planning#115); a component that gets the error runs without a cache by passing a nil *FileCache. Each element must be a single, non-empty path name.

func Get

func Get[T any](c *FileCache, key Key) (T, bool)

Get returns the cached value for key if it exists and has not expired. A nil cache always misses.

func Set

func Set[T any](c *FileCache, key Key, value T) error

Set writes value to the cache under key. On a nil cache it does nothing.

Types

type FileCache

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

FileCache stores JSON-encoded values on disk with a TTL. A nil *FileCache is a valid cache that stores nothing: Get always misses and Set does nothing, so a component whose cache directory is unavailable runs uncached without guarding every call.

func NewFileCache

func NewFileCache(dir string, ttl time.Duration) (*FileCache, error)

NewFileCache creates a cache rooted at dir with the specified TTL.

type Key

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

Key uniquely identifies one cached auditor result.

func NewKey

func NewKey(purl, name, ecosystem, version string) Key

NewKey creates a stable cache key from the given fields. Callers should pass the most specific identity available.

Jump to

Keyboard shortcuts

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