Documentation
¶
Overview ¶
Package cache provides a small file-backed cache for results that are expensive to compute and cheap to invalidate by a version key.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Entry ¶ added in v0.0.41
type Entry struct {
Version string `json:"version"`
Data json.RawMessage `json:"data"`
}
Entry wraps a cached value with a version key for invalidation.
type FileCache ¶
type FileCache struct {
// contains filtered or unexported fields
}
FileCache provides a file-based cache using os.UserCacheDir for OS-agnostic storage. Each entry is a JSON file keyed by a hash of the cache key.
func NewFileCache ¶
NewFileCache creates a new file cache in the given subdirectory under UserDir. For example, NewFileCache("allbctl", "languages") uses ~/.cache/allbctl/languages/ on Linux.
func NewFileCacheInDir ¶
NewFileCacheInDir creates a file cache in an explicit directory. Useful for testing.
func (*FileCache) Delete ¶ added in v0.2.0
Delete removes the entry for key. Deleting an entry that does not exist is not an error.